601
Universit ` a di Roma ‘Tor Vergata’ FACOLT ` A DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni per la certificazione di software secondo uno standard di qualit ` a. Accordo sulle evidenze che il produttore deve fornire al certificatore. Definizione del processo ed implementazione di uno strumento software a supporto. ?? Novembre 2010 Relatore: Chiar.mo Prof. Giovanni Cantone Correlatore: Dr. Davide Falessi Candidato: Emanuele Turella Anno Accademico 2009/2010

Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

Universita di Roma ‘Tor Vergata’FACOLTA DI INGEGNERIA

Corso di Laurea Specialistica in Ingegneria Informatica

Tesi sperimentale

Precondizioni per la certificazione disoftware secondo uno standard di

qualita.

Accordo sulle evidenze che il

produttore deve fornire al

certificatore.

Definizione del processo ed implementazione di unostrumento software a supporto.

?? Novembre 2010

Relatore:

Chiar.mo Prof. Giovanni Cantone

Correlatore:

Dr. Davide Falessi

Candidato:

Emanuele Turella

Anno Accademico 2009/2010

Page 2: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

Questa pagina e stata lasciata intenzionalmente bianca

Page 3: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

Ringraziamenti

‘Perduto e tutto il tempo che in amor non si spende’

Torquato Tasso

Antonella, in questo caso non vale il ”chi ringrazia si toglie dall’obbligo”! Guardan-

domi indietro non saprei contare tutte le innumerevoli volte che sei riuscita a capire i

miei stati d’animo, a sopportarmi nei momenti piu duri, ad aiutarmi ed incitarmi in

quelli delusione, sempre pronta con un sorriso ad illuminare le mie giornate. Grazie

per tutte le volte che ti ho trascurata! Grazie per essere la persona speciale che

rimane sempre al mio fianco, anche quando non me lo merito.

‘[all’ora di cena] A Ma’... ecco... arrivo... un attimo... ho capito... arrivo...’

Un ringraziamento particolare ai miei genitori, che mi hanno sostenuto in questa

lunga avventura senza mai perdere mai la fiducia nei miei confronti.

‘Si decide in fretta di essere amici, ma l’amicizia e un frutto che matura lentamente’

Aristotele

Un sentito grazie a Giuseppe, con cui ho condiviso gioie e dolori, Antonella e

Flaminia, per i progetti finiti bene, Francesco ed Antonello, per le gomitate nelle

costole e le partite a traversone, non meno educative degli esami

‘Il cavolfiore non e altro che un cavolo con un’istruzione universitaria’

Mark Twain

Last but not least, un ringraziamento spetta al Prof. Cantone, per l’opportunita

offertami di lavorare alla presente tesi, e al Dr. Davide Falessi, per l’enorme disponi-

bilita e la pazienza infinita con cui e sempre stato pronto ad ascoltarmi. Un grazie

anche a tutti i miei docenti per avermi dato la possibilita di coltivare la tenacia ed

il pensiero critico.

Le piu felici delle persone, non necessariamente hanno il meglio di ogni cosa;

soltanto traggono il meglio da ogni cosa che capita sul loro cammino

Lunedı, 8 Novembre 2010

Page 4: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

Indice

1 Abstract 1

1.1 Contesto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 Motivazioni . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.3 Obiettivi raggiunti . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.4 Difficolta incontrate . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.5 Conclusioni e risultati . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Introduzione 5

2.1 Contesto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.1.1 Sistemi safety-critical . . . . . . . . . . . . . . . . . . . . . . . 6

2.1.2 Dependability . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.1.2.1 Attributi . . . . . . . . . . . . . . . . . . . . . . . . 8

2.1.2.2 Minacce . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.1.2.3 Mezzi . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.1.3 Sicurezza, evento indesiderato e rischio . . . . . . . . . . . . . 10

2.1.3.1 Gestione dei rischi . . . . . . . . . . . . . . . . . . . 13

2.2 Lo standard IEC-61508 . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.2.1 Scopo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.2.1.1 Struttura . . . . . . . . . . . . . . . . . . . . . . . . 15

2.2.1.2 Concetti . . . . . . . . . . . . . . . . . . . . . . . . . 16

2.2.1.3 Ciclo di vita della sicurezza . . . . . . . . . . . . . . 18

I

Page 5: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

INDICE

2.2.1.4 Safety Integration Level . . . . . . . . . . . . . . . . 21

2.2.2 Il modello concettuale . . . . . . . . . . . . . . . . . . . . . . 22

2.2.2.1 System Concepts . . . . . . . . . . . . . . . . . . . . 22

2.2.2.2 Hazard Concepts . . . . . . . . . . . . . . . . . . . . 24

2.2.2.3 Requirements Concepts . . . . . . . . . . . . . . . . 25

2.2.2.4 Process Concepts . . . . . . . . . . . . . . . . . . . . 26

2.2.2.5 Artifact Concepts . . . . . . . . . . . . . . . . . . . . 26

2.2.2.6 Issue Concepts . . . . . . . . . . . . . . . . . . . . . 27

2.2.2.7 Configuration Management Concepts . . . . . . . . . 28

2.2.2.8 Justification Concepts . . . . . . . . . . . . . . . . . 29

2.2.2.9 Guidance Concepts . . . . . . . . . . . . . . . . . . . 29

2.2.2.10 Domain-specific Concepts . . . . . . . . . . . . . . . 29

2.2.2.11 Lifecycle Activity Concepts . . . . . . . . . . . . . . 30

2.3 Motivazioni al lavoro di tesi . . . . . . . . . . . . . . . . . . . . . . . 31

3 Definizione del processo e strumento a supporto 33

3.1 Elementi di base e visione d’insieme . . . . . . . . . . . . . . . . . . . 33

3.1.1 Il processo di certificazione . . . . . . . . . . . . . . . . . . . . 33

3.1.2 Il problema . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

3.1.3 La soluzione proposta . . . . . . . . . . . . . . . . . . . . . . . 36

3.1.4 Oggetti del dominio del problema . . . . . . . . . . . . . . . . 39

3.1.4.1 Modello concettuale dello standard di qualita . . . . 39

3.1.4.2 Questionario . . . . . . . . . . . . . . . . . . . . . . 41

3.1.4.3 Regole di esclusione e di molteplicita . . . . . . . . . 42

3.1.4.4 Ruoli utente . . . . . . . . . . . . . . . . . . . . . . . 43

3.1.4.5 Accordo tra le parti . . . . . . . . . . . . . . . . . . 43

3.2 Modello architetturale del sistema . . . . . . . . . . . . . . . . . . . . 44

3.2.1 Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

3.2.2 Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

3.2.3 Sistema - rappresentazione dei dati . . . . . . . . . . . . . . . 45

II

Page 6: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

INDICE

3.2.4 Sistema - componenti/interfacce verso l’esterno . . . . . . . . 45

3.3 Flussi approvativi di un accordo fra produttore e certificatore . . . . . 46

3.3.1 Approvazione delle evidenze da fornire . . . . . . . . . . . . . 46

3.3.2 Approvazione del contenuto dei deliverables . . . . . . . . . . 48

3.3.3 Approvazione dei documenti . . . . . . . . . . . . . . . . . . . 48

3.4 Modello entita-relazioni . . . . . . . . . . . . . . . . . . . . . . . . . . 50

3.4.1 Meta-modello dello standard, figura 3.8 . . . . . . . . . . . . . 51

3.4.2 Questionario, figura 3.9 . . . . . . . . . . . . . . . . . . . . . . 52

3.4.3 Organizzazioni, utenti e ruoli, figura 3.10 . . . . . . . . . . . . 53

3.4.4 Accordo, figura 3.11 . . . . . . . . . . . . . . . . . . . . . . . 53

3.4.4.1 Dati di storico, figura 3.12 . . . . . . . . . . . . . . . 55

3.5 Meccanismo di routing fra le domande del questionario . . . . . . . . 56

3.6 Casi d’uso individuati . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

3.6.1 Gestione dei modelli concettuali . . . . . . . . . . . . . . . . . 57

3.6.1.1 Flusso principale . . . . . . . . . . . . . . . . . . . . 60

3.6.2 Gestione dei questionari . . . . . . . . . . . . . . . . . . . . . 62

3.6.2.1 Relazioni con altri casi d’uso . . . . . . . . . . . . . 62

3.6.2.2 Flusso principale . . . . . . . . . . . . . . . . . . . . 62

3.6.2.3 Flusso alternativo F1 - creazione di una nuova do-

manda di un questionario . . . . . . . . . . . . . . . 65

3.6.2.4 Flusso alternativo F2 - creazione di una alternativa

per una domanda . . . . . . . . . . . . . . . . . . . . 67

3.6.2.5 Flusso alternativo F3 - creazione di una regola di

esclusione . . . . . . . . . . . . . . . . . . . . . . . . 70

3.6.2.6 Flusso alternativo F4 - creazione di una regola di

molteplicita . . . . . . . . . . . . . . . . . . . . . . . 72

3.6.3 Gestione degli utenti . . . . . . . . . . . . . . . . . . . . . . . 74

3.6.3.1 Relazioni con altri casi d’uso . . . . . . . . . . . . . 74

3.6.3.2 Flusso principale . . . . . . . . . . . . . . . . . . . . 74

3.6.4 Gestione delle organizzazioni . . . . . . . . . . . . . . . . . . . 76

III

Page 7: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

INDICE

3.6.4.1 Flusso principale . . . . . . . . . . . . . . . . . . . . 76

3.6.5 Gestione dei contratti . . . . . . . . . . . . . . . . . . . . . . . 78

3.6.5.1 Relazioni con altri casi d’uso . . . . . . . . . . . . . 78

3.6.5.2 Flusso principale . . . . . . . . . . . . . . . . . . . . 78

3.6.5.3 Flusso alternativo F1 - creazione di un ruolo . . . . . 78

3.6.6 Gestione dei deliverables di default . . . . . . . . . . . . . . . 83

3.6.6.1 Relazioni con altri casi d’uso . . . . . . . . . . . . . 83

3.6.6.2 Flusso principale . . . . . . . . . . . . . . . . . . . . 83

3.6.7 Gestione dei deliverables del contratto . . . . . . . . . . . . . 83

3.6.7.1 Flusso principale . . . . . . . . . . . . . . . . . . . . 86

3.6.7.2 Flusso alternativo F1 - controllo dei deliverables vuoti

e delle evidenze non mappate . . . . . . . . . . . . . 88

3.6.8 Proposta degli elementi di prova . . . . . . . . . . . . . . . . . 89

3.6.8.1 Relazioni con altri casi d’uso . . . . . . . . . . . . . 89

3.6.8.2 Flusso principale . . . . . . . . . . . . . . . . . . . . 89

3.6.8.3 Flusso alternativo F1 - proposta del contenuto dei

deliverables . . . . . . . . . . . . . . . . . . . . . . . 94

3.6.8.4 Flusso alternativo F2 - proposta delle relazioni fra le

evidenze . . . . . . . . . . . . . . . . . . . . . . . . . 97

3.6.9 Approvazione degli elementi di prova . . . . . . . . . . . . . . 97

3.6.9.1 Flusso principale . . . . . . . . . . . . . . . . . . . . 97

3.6.9.2 Flusso alternativo F1 - approvazione della domanda . 102

3.6.9.3 Flusso alternativo F2 - approvazione del contenuto

dei deliverables . . . . . . . . . . . . . . . . . . . . . 104

3.6.9.4 Flusso alternativo F3 - approvazione dell’istanziazione

delle relazioni . . . . . . . . . . . . . . . . . . . . . . 105

3.6.10 Gestione dei documenti del contratto . . . . . . . . . . . . . . 105

3.6.10.1 Flusso principale . . . . . . . . . . . . . . . . . . . . 106

3.6.10.2 Flusso alternativo F1 - approvazione del documento

o della sua cancellazione . . . . . . . . . . . . . . . . 110

3.7 Pattern, tecnologie e tecniche utilizzate . . . . . . . . . . . . . . . . . 111

IV

Page 8: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

INDICE

3.7.1 Pattern Model-View-Presenter . . . . . . . . . . . . . . . . . . 111

3.7.2 Framework per l’interfaccia web . . . . . . . . . . . . . . . . . 112

3.7.3 Object-relational mapping . . . . . . . . . . . . . . . . . . . . 113

3.7.4 Java Architecture for XML Binding . . . . . . . . . . . . . . . 115

3.8 Metriche . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

3.8.1 Relative al modello concettuale . . . . . . . . . . . . . . . . . 116

3.8.2 Relative allo strumento . . . . . . . . . . . . . . . . . . . . . . 117

3.8.2.1 Stima dell’effort basato sui casi d’uso individuati . . 117

3.8.2.2 Effort finale del progetto . . . . . . . . . . . . . . . . 119

4 Conclusioni e sviluppi futuri 121

4.1 Sviluppi futuri . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

Bibliografia 124

A Documento prodotto dal tool 127

B Modello concettuale dettagliato 147

C Questionario d’esempio 159

D Codice sorgente di EvidenceAgreement 173

D.1 Package it.uniroma2.norge.common . . . . . . . . . . . . . . . . . . . 173

D.1.1 Classe AnswerStatus.java . . . . . . . . . . . . . . . . . . . . . 173

D.1.2 Classe DeliverableStatus.java . . . . . . . . . . . . . . . . . . 174

D.1.3 Classe DeliverableTypes.java . . . . . . . . . . . . . . . . . . . 174

D.1.4 Classe DocumentStatus.java . . . . . . . . . . . . . . . . . . . 174

D.1.5 Classe QuestionStatus.java . . . . . . . . . . . . . . . . . . . . 174

D.1.6 Classe RoleTypes.java . . . . . . . . . . . . . . . . . . . . . . 175

D.2 Package it.uniroma2.norge.controller . . . . . . . . . . . . . . . . . . 175

D.2.1 Classe AgreementCtrl.java . . . . . . . . . . . . . . . . . . . . 175

D.2.2 Classe AssignmentsCtrl.java . . . . . . . . . . . . . . . . . . . 177

V

Page 9: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

INDICE

D.2.3 Classe DefDeliverableCtrl.java . . . . . . . . . . . . . . . . . . 179

D.2.4 Classe DeliverableCtrl.java . . . . . . . . . . . . . . . . . . . . 180

D.2.5 Classe DocumentCtrl.java . . . . . . . . . . . . . . . . . . . . 187

D.2.6 Classe FilloutValidationCtrl.java . . . . . . . . . . . . . . . . 195

D.2.7 Classe LoggedUser.java . . . . . . . . . . . . . . . . . . . . . . 227

D.2.8 Classe LoginException.java . . . . . . . . . . . . . . . . . . . 229

D.2.9 Classe OrganizationCtrl.java . . . . . . . . . . . . . . . . . . . 229

D.2.10 Classe PDFmerge.java . . . . . . . . . . . . . . . . . . . . . . 230

D.2.11 Classe PDFoutput.java . . . . . . . . . . . . . . . . . . . . . . 232

D.2.12 Classe QuestionnairesCtrl.java . . . . . . . . . . . . . . . . . . 248

D.2.13 Classe SaveException.java . . . . . . . . . . . . . . . . . . . . 257

D.2.14 Classe UmlModelCtrl.java . . . . . . . . . . . . . . . . . . . . 258

D.2.15 Classe UsersCtrl.java . . . . . . . . . . . . . . . . . . . . . . . 266

D.3 Package it.uniroma2.norge.ecore . . . . . . . . . . . . . . . . . . . . . 268

D.3.1 Classe Diagram2Java.java . . . . . . . . . . . . . . . . . . . . 268

D.3.2 Classe Ecore2Java.java . . . . . . . . . . . . . . . . . . . . . . 269

D.3.3 Classe Java2Ecore.java . . . . . . . . . . . . . . . . . . . . . . 270

D.4 Package it.uniroma2.norge.model . . . . . . . . . . . . . . . . . . . . 270

D.4.1 Classe AgreementManager.java . . . . . . . . . . . . . . . . . 270

D.4.2 Classe AssignmentManager.java . . . . . . . . . . . . . . . . . 271

D.4.3 Classe ClassManager.java . . . . . . . . . . . . . . . . . . . . 273

D.4.4 Classe DefDeliverablesManager.java . . . . . . . . . . . . . . . 273

D.4.5 Classe DelivCategManager.java . . . . . . . . . . . . . . . . . 275

D.4.6 Classe DeliverablesManager.java . . . . . . . . . . . . . . . . . 276

D.4.7 Classe DocumentsManager.java . . . . . . . . . . . . . . . . . 279

D.4.8 Classe GenericManager.java . . . . . . . . . . . . . . . . . . . 281

D.4.9 Classe ModelManager.java . . . . . . . . . . . . . . . . . . . . 281

D.4.10 Classe OrganizationsManager.java . . . . . . . . . . . . . . . . 284

D.4.11 Classe PackageManager.java . . . . . . . . . . . . . . . . . . . 285

VI

Page 10: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

INDICE

D.4.12 Classe QuestionnaireManager.java . . . . . . . . . . . . . . . . 286

D.4.13 Classe RuleManager.java . . . . . . . . . . . . . . . . . . . . . 291

D.4.14 Classe UserManager.java . . . . . . . . . . . . . . . . . . . . . 293

D.5 Package it.uniroma2.norge.model.jpa . . . . . . . . . . . . . . . . . . 294

D.5.1 Classe Agreement.java . . . . . . . . . . . . . . . . . . . . . . 294

D.5.2 Classe AlternativeAnswer.java . . . . . . . . . . . . . . . . . . 298

D.5.3 Classe AnswerSet.java . . . . . . . . . . . . . . . . . . . . . . 303

D.5.4 Classe AnswsetHistory.java . . . . . . . . . . . . . . . . . . . . 307

D.5.5 Classe Assignment.java . . . . . . . . . . . . . . . . . . . . . . 309

D.5.6 Classe DefaultDeliverable.java . . . . . . . . . . . . . . . . . . 310

D.5.7 Classe DelivCateg.java . . . . . . . . . . . . . . . . . . . . . . 312

D.5.8 Classe Deliverable.java . . . . . . . . . . . . . . . . . . . . . . 314

D.5.9 Classe DeliverableContentHistory.java . . . . . . . . . . . . . . 318

D.5.10 Classe DeliverableEvidence.java . . . . . . . . . . . . . . . . . 320

D.5.11 Classe DeliverableHistory.java . . . . . . . . . . . . . . . . . . 322

D.5.12 Classe DelivSubcateg.java . . . . . . . . . . . . . . . . . . . . 324

D.5.13 Classe DiagChildren.java . . . . . . . . . . . . . . . . . . . . . 327

D.5.14 Classe DiagEdge.java . . . . . . . . . . . . . . . . . . . . . . . 329

D.5.15 Classe Document.java . . . . . . . . . . . . . . . . . . . . . . 332

D.5.16 Classe DocumentHistory.java . . . . . . . . . . . . . . . . . . 333

D.5.17 Classe Entitle.java . . . . . . . . . . . . . . . . . . . . . . . . 335

D.5.18 Classe Evidence.java . . . . . . . . . . . . . . . . . . . . . . . 336

D.5.19 Classe Mclass.java . . . . . . . . . . . . . . . . . . . . . . . . 341

D.5.20 Classe Mfield.java . . . . . . . . . . . . . . . . . . . . . . . . . 345

D.5.21 Classe Mliteral.java . . . . . . . . . . . . . . . . . . . . . . . . 349

D.5.22 Classe Model.java . . . . . . . . . . . . . . . . . . . . . . . . . 350

D.5.23 Classe Mpackage.java . . . . . . . . . . . . . . . . . . . . . . . 352

D.5.24 Classe Organization.java . . . . . . . . . . . . . . . . . . . . . 355

D.5.25 Classe Question.java . . . . . . . . . . . . . . . . . . . . . . . 358

VII

Page 11: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

INDICE

D.5.26 Classe Questionnaire.java . . . . . . . . . . . . . . . . . . . . 363

D.5.27 Classe Relation.java . . . . . . . . . . . . . . . . . . . . . . . 365

D.5.28 Classe Role.java . . . . . . . . . . . . . . . . . . . . . . . . . . 367

D.5.29 Classe RuleExclusion.java . . . . . . . . . . . . . . . . . . . . 369

D.5.30 Classe RuleMulteplicity.java . . . . . . . . . . . . . . . . . . . 371

D.5.31 Classe User.java . . . . . . . . . . . . . . . . . . . . . . . . . . 373

D.6 Package it.uniroma2.norge.web . . . . . . . . . . . . . . . . . . . . . . 376

D.6.1 Classe AgreementUI.java . . . . . . . . . . . . . . . . . . . . . 376

D.6.2 Classe AssignmentUI.java . . . . . . . . . . . . . . . . . . . . 380

D.6.3 Classe DefaultDeliverablesUI.java . . . . . . . . . . . . . . . . 383

D.6.4 Classe DeliverablesUI.java . . . . . . . . . . . . . . . . . . . . 387

D.6.5 Classe DocumentsUI.java . . . . . . . . . . . . . . . . . . . . . 401

D.6.6 Classe EcoreDiagModifier.java . . . . . . . . . . . . . . . . . . 412

D.6.7 Classe FilloutValidationUI.java . . . . . . . . . . . . . . . . . 421

D.6.8 Classe ModelUI.java . . . . . . . . . . . . . . . . . . . . . . . 443

D.6.9 Classe MyLoginForm.java . . . . . . . . . . . . . . . . . . . . 451

D.6.10 Classe MyMenuBar.java . . . . . . . . . . . . . . . . . . . . . 453

D.6.11 Classe OrganizationsUI.java . . . . . . . . . . . . . . . . . . . 455

D.6.12 Classe PieChart.java . . . . . . . . . . . . . . . . . . . . . . . 459

D.6.13 Classe QuestionnaireUI.java . . . . . . . . . . . . . . . . . . . 460

D.6.14 Classe SubWindowManager.java . . . . . . . . . . . . . . . . . 476

D.6.15 Classe TesiwebApplication.java . . . . . . . . . . . . . . . . . 477

D.6.16 Classe UserUI.java . . . . . . . . . . . . . . . . . . . . . . . . 483

D.6.17 Classe ValidationUI.java . . . . . . . . . . . . . . . . . . . . . 487

D.7 Package it.uniroma2.norge.web.fieldfactory . . . . . . . . . . . . . . . 506

D.7.1 Classe AgreementFieldFactory.java . . . . . . . . . . . . . . . 506

D.7.2 Classe AnswerFieldFactory.java . . . . . . . . . . . . . . . . . 508

D.7.3 Classe AnswerHistoryFieldFactory.java . . . . . . . . . . . . . 510

D.7.4 Classe AnswerSetFieldFactory.java . . . . . . . . . . . . . . . 511

VIII

Page 12: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

INDICE

D.7.5 Classe AssignmentFieldFactory.java . . . . . . . . . . . . . . . 512

D.7.6 Classe DefaultDeliverableFieldFactory.java . . . . . . . . . . . 514

D.7.7 Classe DelivContentHistoryFieldFactory.java . . . . . . . . . . 517

D.7.8 Classe DeliverableFieldFactory.java . . . . . . . . . . . . . . . 518

D.7.9 Classe DeliverableHistoryFieldFactory.java . . . . . . . . . . . 522

D.7.10 Classe DocumentHistoryFieldFactory.java . . . . . . . . . . . 522

D.7.11 Classe FillingoutFieldFactory.java . . . . . . . . . . . . . . . . 523

D.7.12 Classe ModelFieldFactory.java . . . . . . . . . . . . . . . . . . 524

D.7.13 Classe OrganizationFieldFactory.java . . . . . . . . . . . . . . 525

D.7.14 Classe QuestionFieldFactory.java . . . . . . . . . . . . . . . . 526

D.7.15 Classe QuestionnaireFieldFactory.java . . . . . . . . . . . . . . 531

D.7.16 Classe ResponseFieldFactory.java . . . . . . . . . . . . . . . . 532

D.7.17 Classe RuleExcFieldFactory.java . . . . . . . . . . . . . . . . . 533

D.7.18 Classe RuleMulFieldFactory.java . . . . . . . . . . . . . . . . 535

D.7.19 Classe UserFieldFactory.java . . . . . . . . . . . . . . . . . . . 537

D.8 Package it.uniroma2.norge.web.support . . . . . . . . . . . . . . . . . 539

D.8.1 Classe EvidenceMapBean.java . . . . . . . . . . . . . . . . . . 539

D.8.2 Classe ExclusionBean.java . . . . . . . . . . . . . . . . . . . . 542

D.8.3 Classe FillingBean.java . . . . . . . . . . . . . . . . . . . . . . 543

D.8.4 Classe MenuLinks.java . . . . . . . . . . . . . . . . . . . . . . 546

D.8.5 Classe StringBean.java . . . . . . . . . . . . . . . . . . . . . . 546

D.8.6 Classe ValidationBean.java . . . . . . . . . . . . . . . . . . . . 546

D.9 Package it.uniroma2.norge.web.widgetset . . . . . . . . . . . . . . . . 549

D.9.1 File TesiwebappWidgetset.gwt.xml . . . . . . . . . . . . . . . 549

D.10 Package it.jaxb.ecore . . . . . . . . . . . . . . . . . . . . . . . . . . . 549

D.10.1 Classe Details.java . . . . . . . . . . . . . . . . . . . . . . . . 549

D.10.2 Classe EAnnotations.java . . . . . . . . . . . . . . . . . . . . 550

D.10.3 Classe EClassifiers.java . . . . . . . . . . . . . . . . . . . . . . 551

D.10.4 Classe ELiterals.java . . . . . . . . . . . . . . . . . . . . . . . 553

IX

Page 13: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

INDICE

D.10.5 Classe EOperations.java . . . . . . . . . . . . . . . . . . . . . 554

D.10.6 Classe EPackage.java . . . . . . . . . . . . . . . . . . . . . . . 555

D.10.7 Classe EStructuralFeatures.java . . . . . . . . . . . . . . . . . 556

D.10.8 Classe ESubpackages.java . . . . . . . . . . . . . . . . . . . . 558

D.10.9 Classe ObjectFactory.java . . . . . . . . . . . . . . . . . . . . 560

D.11 Package it.jaxb.ecorediag . . . . . . . . . . . . . . . . . . . . . . . . . 561

D.11.1 Classe Bendpoints.java . . . . . . . . . . . . . . . . . . . . . . 561

D.11.2 Classe Children.java . . . . . . . . . . . . . . . . . . . . . . . 562

D.11.3 Classe Details.java . . . . . . . . . . . . . . . . . . . . . . . . 564

D.11.4 Classe Diagram.java . . . . . . . . . . . . . . . . . . . . . . . 565

D.11.5 Classe EAnnotations.java . . . . . . . . . . . . . . . . . . . . 567

D.11.6 Classe Edges.java . . . . . . . . . . . . . . . . . . . . . . . . . 569

D.11.7 Classe Element.java . . . . . . . . . . . . . . . . . . . . . . . . 571

D.11.8 Classe LayoutConstraint.java . . . . . . . . . . . . . . . . . . 573

D.11.9 Classe ObjectFactory.java . . . . . . . . . . . . . . . . . . . . 574

D.11.10Classe SourceAnchor.java . . . . . . . . . . . . . . . . . . . . 575

D.11.11Classe Styles.java . . . . . . . . . . . . . . . . . . . . . . . . . 576

D.11.12Classe TargetAnchor.java . . . . . . . . . . . . . . . . . . . . . 578

D.12 Package WebContent . . . . . . . . . . . . . . . . . . . . . . . . . . . 579

D.12.1 File index.html . . . . . . . . . . . . . . . . . . . . . . . . . . 579

D.13 Package WebContent.META-INF . . . . . . . . . . . . . . . . . . . . 579

D.13.1 File orm.xml . . . . . . . . . . . . . . . . . . . . . . . . . . . 579

D.13.2 File persistence.xml . . . . . . . . . . . . . . . . . . . . . . . . 580

D.14 Package WebContent.WEB-INF . . . . . . . . . . . . . . . . . . . . . 581

D.14.1 File web.xml . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581

X

Page 14: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

Elenco delle figure

2.1 Statistiche sulle cause d’incidente prodotte dalla HSE . . . . . . . . . 6

2.2 fault pathology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2.3 Relazioni tra i concetti legati alla sicurezza . . . . . . . . . . . . . . . 11

2.4 lo spazio del rischio . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.5 matrice del livello di rischio per classe di probabilita e di gravita . . . 12

2.6 Concetti generali della riduzione del rischio (estratto da [IEC98], parte

5) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.7 Interazioni fra il processo di sviluppo ed il processo di gestione dei rischi 14

2.8 EUC e relativo sistema di controllo . . . . . . . . . . . . . . . . . . . 17

2.9 esempio di EUCCS (del SIS) . . . . . . . . . . . . . . . . . . . . . . . 17

2.10 Ciclo di vita della sicurezza . . . . . . . . . . . . . . . . . . . . . . . 19

2.11 Ciclo di vita del hardware . . . . . . . . . . . . . . . . . . . . . . . . 20

2.12 Ciclo di vita del software . . . . . . . . . . . . . . . . . . . . . . . . . 21

2.13 Il modello concettuale completo . . . . . . . . . . . . . . . . . . . . . 23

2.14 System concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.15 Hazard Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.16 Requirements Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . 25

2.17 Process Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

2.18 Artifact Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

2.19 Issue Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

2.20 Configuration Management Concepts . . . . . . . . . . . . . . . . . . 28

XI

Page 15: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

ELENCO DELLE FIGURE

2.21 Justification Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . 29

2.22 Guidance Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

3.1 diagramma a blocchi del processo (da sostituire con un BPEL) . . . . 34

3.2 Oggetti del dominio del problema . . . . . . . . . . . . . . . . . . . . 40

3.3 Architettura dell’applicazione software . . . . . . . . . . . . . . . . . 45

3.4 Diagramma a stati’iter approvativo delle evidenze . . . . . . . . . . . 46

3.5 Diagramma a stati’iter approvativo delle domande . . . . . . . . . . . 47

3.6 Diagramma a stati’iter approvativo dei documenti . . . . . . . . . . . 49

3.7 Diagramma entita-relazione . . . . . . . . . . . . . . . . . . . . . . . 50

3.8 Diagramma ER, meta-modello dello standard . . . . . . . . . . . . . 51

3.9 Diagramma ER, questionario . . . . . . . . . . . . . . . . . . . . . . 52

3.10 Diagramma ER, organizzazioni-utenti-ruoli . . . . . . . . . . . . . . . 53

3.11 Diagramma ER, accordo . . . . . . . . . . . . . . . . . . . . . . . . . 54

3.12 Diagramma ER, dati di storico . . . . . . . . . . . . . . . . . . . . . 55

3.13 Diagramma dei casi d’uso individuati . . . . . . . . . . . . . . . . . . 58

3.14 Gestione dei modelli concettuali, flusso principale . . . . . . . . . . . 59

3.15 Lista modelli UML caricati . . . . . . . . . . . . . . . . . . . . . . . . 60

3.16 Inserimento della descrizione del modello . . . . . . . . . . . . . . . . 60

3.17 Maschera per il caricamento del file . . . . . . . . . . . . . . . . . . . 61

3.18 Scelta del file da caricare . . . . . . . . . . . . . . . . . . . . . . . . . 61

3.19 Progresso di caricamento del file . . . . . . . . . . . . . . . . . . . . . 61

3.20 Lista modelli UML caricati (dopo l’inserimento) . . . . . . . . . . . . 62

3.21 Gestione dei questionari, flusso principale . . . . . . . . . . . . . . . . 63

3.22 Inserimento di un nuovo questionario . . . . . . . . . . . . . . . . . . 63

3.23 Gestione dei questionari, creazione di una nuova domanda (flusso

alternativo F1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

3.24 Dettaglio di un questionario . . . . . . . . . . . . . . . . . . . . . . . 65

3.25 Lista domanda di un questionario e torte della copertura del modello 66

3.26 Creazione di una domanda . . . . . . . . . . . . . . . . . . . . . . . . 67

XII

Page 16: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

ELENCO DELLE FIGURE

3.27 Gestione dei questionari, creazione di una nuova alternativa (flusso

alternativo F2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

3.28 Modifica di una domanda e lista alternative . . . . . . . . . . . . . . 69

3.29 Creazione di una domanda . . . . . . . . . . . . . . . . . . . . . . . . 69

3.30 Gestione dei questionari, creazione di una nuova regola di esclusione

(flusso alternativo F3) . . . . . . . . . . . . . . . . . . . . . . . . . . 70

3.31 Modifica di una alternativa . . . . . . . . . . . . . . . . . . . . . . . . 71

3.32 Lista delle regole di esclusione per una domanda . . . . . . . . . . . . 71

3.33 Creazione di una regola di esclusione . . . . . . . . . . . . . . . . . . 72

3.34 Gestione dei questionari, creazione di una nuova regola di molteplicita

(flusso alternativo F4) . . . . . . . . . . . . . . . . . . . . . . . . . . 73

3.35 Creazione di una regola di molteplicita . . . . . . . . . . . . . . . . . 73

3.36 Gestione degli utenti, flusso principale . . . . . . . . . . . . . . . . . 74

3.37 Lista delle utenze . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

3.38 Inserimento di una nuova utenza . . . . . . . . . . . . . . . . . . . . . 75

3.39 Gestione delle organizzazioni, flusso principale . . . . . . . . . . . . . 76

3.40 Lista delle organizzazioni . . . . . . . . . . . . . . . . . . . . . . . . . 77

3.41 Inserimento di una nuova organizzazione . . . . . . . . . . . . . . . . 77

3.42 Gestione dei contratti, flusso principale . . . . . . . . . . . . . . . . . 79

3.43 Lista dei contratti contratto . . . . . . . . . . . . . . . . . . . . . . . 80

3.44 Inserimento di un nuovo contratto . . . . . . . . . . . . . . . . . . . . 80

3.45 Gestione dei contratti, creazione di un ruolo (flusso alternativo F1) . 81

3.46 Dettaglio di un contratto . . . . . . . . . . . . . . . . . . . . . . . . . 82

3.47 Lista dei ruoli utente per un contratto . . . . . . . . . . . . . . . . . 82

3.48 Creazione di una ruolo utente . . . . . . . . . . . . . . . . . . . . . . 82

3.49 Gestione dei deliverables di default, flusso principlae . . . . . . . . . . 84

3.50 Lista dei deliverables di default . . . . . . . . . . . . . . . . . . . . . 85

3.51 Inserimento di una nuova organizzazione . . . . . . . . . . . . . . . . 85

3.52 Gestione dei deliverables del contratto, flusso principlae . . . . . . . . 86

3.53 Lista dei deliverables per il contratto . . . . . . . . . . . . . . . . . . 87

XIII

Page 17: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

ELENCO DELLE FIGURE

3.54 Inserimento di un nuovo deliverable per il contratto . . . . . . . . . . 87

3.55 Gestione dei deliverables del contratto, controllo della matrice di

mappatura (flusso alternativo F1) . . . . . . . . . . . . . . . . . . . . 88

3.56 Matrice evidenze-deliverables . . . . . . . . . . . . . . . . . . . . . . 89

3.57 Proposta degli elementi di prova, flusso principiale . . . . . . . . . . . 90

3.58 Statistiche relative all’approvazione delle domande (supplier) . . . . . 91

3.59 Lista delle domande per un package del modello concettuale . . . . . 92

3.60 Proposta delle evidenze . . . . . . . . . . . . . . . . . . . . . . . . . . 93

3.61 Inserimento di commenti alle modifiche del set di evidenze proposte . 94

3.62 Proposta degli elementi di prova, proposta della mappatura nei de-

liverables (flusso alternativo F1) . . . . . . . . . . . . . . . . . . . . . 95

3.63 Proposta del contenuto dei deliverables . . . . . . . . . . . . . . . . . 96

3.64 Proposta del contenuto dei deliverables . . . . . . . . . . . . . . . . . 97

3.65 Approvazione delle evidenze, prima parte del flusso principale . . . . 98

3.66 Approvazione delle evidenze, seconda parte del flusso principale e

approvazione della domanda (flusso altenativo F1) . . . . . . . . . . . 99

3.67 Statistiche relative all’approvazione delle domande (certifier) . . . . . 100

3.68 Lista delle domande per un package del modello concettuale . . . . . 101

3.69 Approvazione delle evidenze . . . . . . . . . . . . . . . . . . . . . . . 102

3.70 Inserimento di commenti alle modifiche dell’approvazione delle evidenze103

3.71 Approvazione della domanda . . . . . . . . . . . . . . . . . . . . . . . 103

3.72 Approvazione delle evidenze, approvazione del contenuto dei deliver-

able (flusso alternativo F2) . . . . . . . . . . . . . . . . . . . . . . . . 104

3.73 Approvazione del contenuto dei deliverables . . . . . . . . . . . . . . 105

3.74 Approvazione del contenuto dei deliverables . . . . . . . . . . . . . . 106

3.75 Gestione dei documenti del contratto, flusso principale . . . . . . . . 107

3.76 Lista dei documenti del contratto . . . . . . . . . . . . . . . . . . . . 108

3.77 Maschera di personalizzazione dell’anteprima di un nuovo documento 108

3.78 Maschera di personalizzazione del nuovo documento . . . . . . . . . . 109

3.79 Gestione dei documenti del contratto, approvazione di un documento

(flusso alternativo F1) . . . . . . . . . . . . . . . . . . . . . . . . . . 110

XIV

Page 18: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

ELENCO DELLE FIGURE

3.80 Dettaglio del documento del contratto . . . . . . . . . . . . . . . . . 111

3.81 Interazioni fra i componenti del pattern Model-View-Presenter . . . . 112

3.82 Architettura del framework Vaadin . . . . . . . . . . . . . . . . . . . 113

3.83 Schema di Toplink, predecessore di EclipseLink . . . . . . . . . . . . 114

3.84 Schema generale di funzionamento di JAXB . . . . . . . . . . . . . . 115

3.85 linee di codice totali e linee modificate per data . . . . . . . . . . . . 120

XV

Page 19: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

Capitolo 1Abstract

‘Una vigile e provvida paura e

la madre della sicurezza’

attribuita a Edmund Burke

1.1 Contesto

I sistemi software trovano impiego in un numero di applicazioni sempre mag-

giore grazie alla loro intrinseca flessibilita e convenienza. Alcuni di questi impieghi,

come ad esempio le centrali nucleari, i mezzi di trasporto e le apparecchiature med-

icali, possono pero risultare critici per la sicurezza nel caso in cui si verifichi un

malfunzionamento dei sistemi che li governano.

I sistemi la cui disfunzione puo causare danni a persone, oggetti e ambiente sono

detti ‘safety-critical’ e sono caratterizzati dalla proprieta di ‘dependability’, ovvero,

l’attendibilita del sistema, che consente di riporre fiducia nei servizi che il sistema

offre.

Gli standard di qualita specificano in dettaglio i requisiti che i sistemi safety-

critical devono soddisfare per essere considerati sicuri. La certificazione e il giudizio

formale con il quale, una autorita garante, attesta che un sistema e stato progettato

e sviluppato per assicurare l’affidabilita e la sicurezza.

1

Page 20: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 1. ABSTRACT

1.2 Motivazioni

Lo standard di qualita IEC-61508 fornisce la metodologia generica del ciclo di

vita per la produzione di sistemi ‘safety-critical’ e, generalmente, e considerato lo

standard generico migliore disponibile per la gestione della sicurezza funzionale nel

software. Allo stesso modo, pero, e anche largamente considerato come difficoltoso

da usare e costoso da implementare. L’interpretazione pratica dello standard e spesso

percepita come complicata ma con le linee guida appropriate, ed una certa quantita

di training, gli ingegneri in breve tempo si trovano bene nell’usare le metodologie e

con i principi del ciclo di vita.

Per di piu, sempre piu spesso, gli organismi di regolamentazione richiedono, ai

produttori, di fornire evidenze oggettive per dimostrare che gli elementi software

di un sistema sono sufficientemente sicuri. Le ricerche esistenti non si sono focal-

izzate molto nel caratterizzare precisamente che cosa puo essere una evidenza. Di

conseguenza, i produttori di sistemi sono lasciati praticamente senza indicazioni

su quali elementi di prova raccogliere durante la produzione del software. Questo

ha portato i team di sviluppo a dover recuperare le evidenze dopo la conclusione

dello sviluppo del sistema: questo e un compito estremamente costoso e talvolta

impraticabile.

La IEC 61508 fornisce alcune indicazioni per la raccolta di informazioni relative

alla sicurezza ed alla certificazione, ma queste sono prevalentemente testuali, non

struttura, e non sono espresse in una forma precisa, data la genericita dello stan-

dard. Un problema tipico dei produttori, di conseguenza, e che non sempre e chiaro

quali documenti, e a quale livello di dettaglio, dovrebbero fornire a sostegno della

sicurezza.

1.3 Obiettivi raggiunti

Sulla base delle difficolta evidenziate, e stato necessario studiare il processo di

certificazione di un software secondo standard di qualita, in modo da poterlo razion-

alizzare tramite reingegnerizzazione. L’obiettivo raggiunto e stato la definizione di

un nuovo processo, preliminare al precedente, che porta alla determinazione di un

accordo, tra produttore e certificatore, sulle evidenze da fornire per la certificazione.

Inoltre ho sviluppato uno strumento software a supporto che consente:

1. al produttore di comprendere meglio lo standard e di conoscere a priori gli ele-

menti di prova e i documenti da collezionare durante lo sviluppo del prodotto;

2

Page 21: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 1. ABSTRACT

2. al certificatore di trasmettere le proprie aspettative e ottenere documenti con

struttura e contenuti adeguati.

1.4 Difficolta incontrate

Le difficolta che ho incontrato sono state, da un lato, di carattere tecnologico, dal-

l’altro, di carattere gestionale, dovute alla natura prototipale del tool che ha richiesto

molta gestione dei cambiamenti nei requisiti. Al contrario, le conoscenze acquisite

durante la carriera universitaria, mi hanno permesso di gestire la complessita del

progetto senza eccessive difficolta.

Le problematiche tecnologiche sono legate alla scelta del framework per lo svilup-

po dell’interfaccia web. All’inizio del progetto, infatti, il framework, sebbene maturo

e molto ben documentato, aveva alcune lacune per cui e stato difficoltoso trovare

soluzioni valide. Ad oggi e stato modificato in molte parti rendendo l’uso ancora piu

semplice ed immediato. Inoltre e stato arricchito con molti moduli sviluppati dalla

comunita e, sul sito, e disponibile un discreto repository di moduli che verranno

integrati nelle prossime versione ma che possono essere utilizzati insieme alla release

ussiciale di Vaadin.

Dal punto di vista della gestione dei requisiti, l’aver adottato fin dall’inizio il

pattern Model-View-Presenter ha consentito la mitigazione delle problematiche an-

che in mancanza di un sistema di un sistema di tracciabilita fra i requisiti e gli

oggetti sviluppati. Sotto questo aspetto, anche l’uso di un approccio iterativo ed

incrementale e stato di grande aiuto al raggiungimento degli obiettivi.

1.5 Conclusioni e risultati

Questa tesi ha avuto come obiettivo primario la creazione di un mezzo con il

quale il certificatore puo trasferire la sua esperienza e competenza al produttore,

affinche egli acquisisca familiarita con uno standard completo e complesso come il

IEC-61508. Un altro obiettivo, non meno importante, e la possibilita, per il produt-

tore, di superare il divario generato dalla attuale mancanza di una caratterizzazione

sistematica degli elementi di prova. Egli e messo in condizioni di conoscere a priori

le evidenze da collezionare, in modo tale da poter svolgere questa attivita durante il

processo di sviluppo del prodotto, evitando costosi interventi successivi al rilascio.

3

Page 22: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 1. ABSTRACT

EvidenceAgreement e uno strumento di supporto per la definizione di un con-

tratto tra un produttore e certificatore. Il tool, tramite un questionario automa-

tizzato basato sullo standard, guida il produttore ed il certificatore in una serie di

incontri, preliminari al processo di verifica vero e proprio, utili per stabilire alcuni

parametri della specializzazione del modello generico e instradare le successive in-

terazioni. L’applicazione produce un contratto informale (o formale) che le aprti

possono anche firmare. Nel contratto e definito l’accordo sulle evidenze che il pro-

duttore dovra fornire al team di controllo, i deliverables che le raccolgono, e la catena

di relazioni fra gli elmenti di prova.

Comprendere le necessita degli utenti e degli stakeholders ha richiesto molto

tempo. Specialmente per capire le problematiche e gli errori tipici delle aziende che

si avvicinano per la prima volta alla certificazione, oppure all’uso dello standard

IEC-61508.

Gli elementi innovativi della tesi si concentrano sulla definizione di un processo,

propedeutico a quello di certificazione di un prodotto, il cui obiettivo e la semplifi-

cazione e la razionalizzazione di quest’ultimo, con conseguente riduzione del costo

che deve sopportare un produttore di sistemi software ‘safety-critical’, sia termini di

sviluppo che di verifica.

4

Page 23: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

Capitolo 2Introduzione

‘If something can go wrong,

then it will,

eventually in the most critical

way’

Variazione della Legge di

Murphy

2.1 Contesto

Il software ed i sistemi computerizzati, grazie alla intrinseca flessibilita e conve-

nienza, trovano impiego in un numero di applicazioni sempre maggiore. Alcune di

queste, come ad esempio le centrali nucleari, i mezzi di trasporto e le apparecchiature

medicali, possono risultare critici per la sicurezza.

Un certo numero di eventi di questa natura sono stati segnalati e, in molti casi,

sembrerebbe che tali disastri avrebbero potuto essere evitati se fosse stato utilizzato

un processo piu rigoroso nello sviluppo del software. La Health & Safety Executive

(UK) ha prodotto a tal proposito uno statistica che individua le principali cause di

incidenti, riportate in figura 2.1: si puo notare che la specifica dei requisiti e la ges-

tione dei cambiamenti apportino il maggior contributo arrivando, cumulativamente

al 64%.

Tra il 1996 (ANSI/ISA SP84.01) ed il 2000 (CEI/IEC 61508), diversi organismi

hanno emanato degli standard per guidare lo sviluppo di sistemi safety-critical, in

risposta al crescente numero di incidenti degli anni precedenti [WEWR09, Lio96]:

5

Page 24: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Figura 2.1: Statistiche sulle cause d’incidente prodotte dalla HSE

• tra il 1985 ed il 1987, la Therac-25, una attrezzatura radioterapica ha provocato

tre vittime;

• il 25 Febbraio 1991 il sistema di difesa Patriot non e riuscito ad abbattere un

missile SCUD che ha causato 28 morti e 98 feriti;

• il 20 Dicembre 1995 il volo 965 della American Airlines cade provocando 159

vittime;

• il 4 Giugno 1996 l’Ariane5 si e distrutto in volo quaranta secondi dopo il lancio;

Gli standard di qualita specificano in dettaglio i requisiti che i sistemi safety-

critical devono soddisfare per essere considerati sicuri. La certificazione e il giudizio

formale con il quale, una autorita garante, attesta che un sistema e stato progettato

e sviluppato per assicurare l’affidabilita e la sicurezza dei servizi offerti, nei confronti

degli utenti, dell’ambiente in cui operano e del sistema stesso.

2.1.1 Sistemi safety-critical

Un sistema, inteso come un insieme di elementi assemblati per soddisfare scopi

ben determinati, diventa critico quando esiste la possibilita che un suo fallimento

possa avere gravi conseguenze sulla vita umana, l’ambiente del sistema o l’esistenza

stessa dell’organizzazione in cui opera.

Si individuano, quindi, tre categorie di sistemi critici:

• Safety-critical: sono quei sistemi il cui fallimento puo risultare in perdite di

vita umana, infortuni o danni importanti all’ambiente;

6

Page 25: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

• Mission-critical: sistemi la cui failure puo comportare il conseguente fallimento

di un’attivita;

• Business-critical: sistemi la cui failure puo comportare ingenti perdite di denaro.

Questo lavoro di tesi e concentrato sulla prima categoria di sistemi.

I sistemi informatici critici per la sicurezza vengono applicati, ad esempio, in

ambito [IBN97]:

• militare: i sistemi di lancio di armi e i programmi spaziali.

• trasporti: controllo del traffico aereo, sistemi fly-by-wire a bordo di aerei,

sistemi di apparato centrale per i treni, e sistemi di computer in auto.

• energia: controllo di centrali nucleare.

• medicina: apparecchi per la radioterapia, monitoraggio medico e robot medi-

cali.

• industria: controllo del ciclo produttivo in cui sono coinvolte sostanze tossiche

o robot.

• comunicazione: sistema di gestione delle ambulanze e la parte del sistema

telefonico per le chiamate d’emergenza.

Per questo, il software gioca un ruolo fondamentale in quasi ogni aspetto della nostra

vita quotidiana.

2.1.2 Dependability

La definizione di sicurezza funzionale, o dependability, e stata espressa dal J.C.

Laprie (manca un riferimento bibliografico, articolo del CERN):

‘e definito come l’attendibilita di un sistema computerizzato che con-

sente di riporre la giusta fiducia sul servizio che esso offre.’

Coerentemente con questa definizione, la sicurezza funzionale ha un duplice

obiettivo:

• garantire che i sistemi funzionino

• e che funzionino in regime di sicurezza.

Pertanto, la dependability puo essere vista come un metodo per sviluppare un sis-

tema che gode delle proprieta di affidabilita, disponibilita, manutenibilita e sicurezza.

7

Page 26: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

2.1.2.1 Attributi

Una definizione alternativa, di carattere quantitativo, che offre il criterio per

decidere se il sistema sia dependable e il seguente:

la capacita di evitare disservizi che sono piu frequenti e piu gravi di

quanto sia accettabile per l’utente.

La dependability e un concetto che comprende i seguenti attributi:

• disponibilita (availability): in relazione alla rapidita di risposta, o alla pron-

tezza d’uso; si puo esprimere come il rapporto fra il tempo nel quale si fornisce

un servizio corretto ed il tempo totale di esercizio;

• affidabilita (reliability): la continuita del servizio corretto; si esprime come la

probabilita che un sistema funzioni correttamente (porti a termine il compi-

to per cui e progettato), per un intervallo di tempo stabilito, in condizioni

operative stabilite;

• sicurezza (safety): assenza di conseguenze catastrofiche per l’utente e l’ambi-

ente;

• riservatezza o protezione (confidentiality): assenza di diffusione non autoriz-

zata delle informazioni e/o manipolazioni di informazioni private;

• integrita (integrity): prevenzione da alterazioni improprie del sistema ;

• manutenibilita (maintainability): capacita di subire modifiche e riparazioni.

In un certo senso la safety sembra imporre dei vincoli meno stringenti rispetto a

quelli di affidabilita ma, in realta, la definizione fa riferimento a ‘condizioni operative

stabilite’: queste ultime possono anche non corrispondere alle condizione operative

reali in cui si trova il sistema mentre lavora.

2.1.2.2 Minacce

L’avaria (failure) e la transizione dall’erogazione di un servizio corretto a un

servizio non in linea con la funzione del sistema. La conseguenza dell’avaria e un in-

cidente. La transizione da una failure (servizio improprio) al normale funzionamento

e il cosiddetto ripristino di sistema (system restoration).

8

Page 27: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Un errore (error) e quella parte dello stato del sistema che puo causare un suc-

cessivo fallimento: una failure occorre quando si verifica un errore che altera un

servizio.

Un fault (difetto) e la causa (ipotizzata o meno) di un errore.

Una scorretta programmazione inserisce, nel codice eseguibile, un difetto. Esso

e latente fino a quando diventa attivo producendo un errore. Un errore e rilevato se

la sua presenza e segnalata da un messaggio o un segnale prodotto dal sistema. Gli

errori presenti ma non rilevati sono latenti.

Un difetto in origine causa un errore all’interno di uno o piu componenti del

sistema, ma la failure del sistema non occorrera fin quando l’errore non raggiungera

l’interfaccia di sistema, cioe non produrra effetti visibili. Quanto descritto viene

detta fault pathology, cioe la relazione che intercorre tra difetti, errori e failure. La

figura 2.2 schematizza queste relazioni.

Figura 2.2: fault pathology

2.1.2.3 Mezzi

Sono previsti diversi strumetni in grado di aumentare il grado di dependability

del sistema, mitigando in vari modi le minacce appena descritte. La scelta del

particolare approccio dipende dalla tipologia di sistema e dallo specifico attributo

che si vuole migliorare.

• Fault prevention

si riferisce ai modi con cui prevenire l’occorrenza di difetti (faults) nel sistema.

Questo risultato si ottiene attraverso tecniche di controllo della qualita durante

la fase di design e realizzazione dell’hardware e del software.

9

Page 28: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

• Fault tolerance

come fornire un servizio corretto in presenza di difetti attivi. Esso e general-

mente implementato da tecniche di error-detection (rilevamento dell’errore) e

successivo ripristino del sistema. Il rilevamento dell’errore origina un segnale o

un messaggio di errore all’interno del sistema. Esistono due classi di tecniche

di error-detection:

1. concorrente, che ha luogo durante la fornitura del servizio

2. preemptive, attuata mentre la fornitura del servizio e sospesa, consiste

nella ricerca di errori latenti e difetti dormienti.

• Fault removal

come ridurre il numero o la gravita dei difetti durante la fase di sviluppo oppure

durante la vita operativa di un sistema. La rimozione dei difetti durante la

fase di sviluppo di un sistema consiste di tre passi:

1. Verifica, dove si controlla se il sistema aderisce o meno a determinate

proprieta fissate dalle condizioni di verifica.

2. Diagnosi, che permette di individuare locazione e tipologia di difetto.

3. Correzione

• Fault Forecasting

come stimare il numero attuale di difetti, l’evoluzione futura e le relative con-

seguenze. Una tale previsione e condotta eseguendo una valutazione del com-

portamento del sistema in funzione delle occorrenze dei difetti, ossia dei difetti

attivati, che ha due aspetti:

– Valutazione qualitativa, dove s’identificano e classificano le modalita di

fallimento o la combinazione di eventi (fallimenti e relative condizioni del

sistema) che potrebbero portare ad una failure del sistema.

– Valutazione quantitativa, allo scopo di valutare, in termini di probabilita,

il grado di soddisfazione degli attributi della dependability.

2.1.3 Sicurezza, evento indesiderato e rischio

La sicurezza (safety) di un sistema e definita da [IEC98] come: la liberta da un

rischio inaccettabile di ferimento delle persone o di danni alla salute, direttamente

o indirettamente, a seguito di un evento indesiderato.

10

Page 29: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Tale definizione non e completa ma dipende da una serie di concetti, le cui

relazioni sono riportate in figura 2.3.

Figura 2.3: Relazioni tra i concetti legati alla sicurezza

L’evento indesiderato (undesired event), o incidente, e un fenomeno imprevis-

to che puo provocare il decesso di individui, lesioni, malattie professionali, oppure

perdita o danni ad attrezzature, beni, all’ecosistema e all’impianto stesso.

Il rischio (risk), in modo informale esso e: un evento o una azione che

• e associato ad una perdita;

• coinvolge anche un certo numero di scelte;

• coinvolge l’incertezza o dei pericoli.

Il pericolo (danger) e una condizione esistente o potenziale che puo causare o

contribuire ad un incidente .Il concetto di incertezza e relazionato con la conoscenza

parziale di informazioni: se tale conoscenza fosse completa, infatti, non vi sarebbe

alcuna incertezza ed il rischio potrebbe essere determinato con precisione. Natural-

mente, nello sviluppo di sistemi complessi, questo e irrealizzabile.

Dal punto di vista formale possiamo definire il rischio come: il prodotto della

probabilita che si verifichi un incidente per la gravita della potenziali conseguenze.

Se consideriamo la probabilita P e la gravita G come le uniche componenti di un

evento indesiderato, esso puo essere posizionato graficamente su un piano cartesiano

che ha queste due dimensioni come assi ortogonali. Tale piano prende il nome di

‘spazio di rischio’. Il grafico corrisponde alla matrice del rischio definita, con lievi

differenze, in molti standard di qualita. Quello riportato in figura 2.5 e un esempio:

Tornando allo schema in figura 2.4 esistono due modalita per abbassare il rischio di

incidente:

11

Page 30: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Figura 2.4: lo spazio del rischio

Figura 2.5: matrice del livello di rischio per classe di probabilita e di gravita

1. attenuazione: rappresentata dalla freccia verticale, consiste nella diminuzione

della gravita delle conseguenze dell’incidente;

2. prevenzione: rappresentata dalla freccia orizzontale,corrisponde alla dimin-

uzione della probabilita che l’evento occorra.

L’abbassamento del rischio introduce altri due concetti complementari, riportati

graficamente in figura 2.6 :

1. riduzione del rischio al livello accettabile: e la porzione di rischio che viene

eliminata attraverso la mitigazione o la prevenzione;

2. rischio residuo: e il rischio marginale dell’evento indesiderato che si posiziona

al di sotto della curva di rischio accettabile.

12

Page 31: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Figura 2.6: Concetti generali della riduzione del rischio (estratto da [IEC98], parte5)

2.1.3.1 Gestione dei rischi

La gestione del rischio (risk management) e il processo mediante il quale si misura

o si stima il rischio e successivamente si sviluppano delle strategie per governarlo.

La figura 2.71 schematizza i passi fondamentali della gestione del rischio e, inoltre,

evidenzia l’impatto che questi hanno sul normale processo di sviluppo del sistema.

Innanzitutto occorre sottolineare che gli standard definiscono, oltre ai requisiti

che il prodotto deve soddisfare, anche le linee guide con cui operare la gestione del

rischio.

Questo processo si compone di:

1. analisi dei pericoli: produce una lista di possibili pericoli ed incidenti;

2. analisi del rischio: stima il livello di integrita del sistema2 che guida la proget-

tazione del prodotto;

3. valutazione del rischio: definisce le corrette strategie per mitigare/prevenire i

rischi da cui sono derivati nuovi requisiti;

4. riduzione del rischio: produce le modalita operative per la prevenzione dei

rischi.

1estratta da [DMN]2concetto che viene approfondito nel capitolo successivo

13

Page 32: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Figura 2.7: Interazioni fra il processo di sviluppo ed il processo di gestione dei rischi

Da notare come i due processi paralleli, che iniziano dallo standard, terminano in

una collezione di evidenze: esse sono le prove del rispetto dello standard e consentono

la certificazione del prodotto.

14

Page 33: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

2.2 Lo standard IEC-61508

‘The nice thing about standards

is that you have so many to

choose from; furthermore, if you

do not like any of them, you can

just wait for next year’s model.’

Attribuito al Prof. Andrew

Tanembaum

2.2.1 Scopo

Lo IEC 61508 e uno standard insternazionel per la sicurezza funzionale di ap-

parecchiature E/E/PES3. La definizione dello standard e iniziata negli anni ’80,

quando la Advisory Committee of Safety (ACOS) di IEC istituı una task-force per

prendere in considerazione i problemi di standardizzazione sollevati dall’uso di ap-

parecchiature PES. In quel periodo, molti organismi di regolamentazione proibi-

vano l’uso di qualsiasi apparecchiatura software-based in applicazioni critiche per la

sicurezza.

IEC 61508 e uno standard ’generico’, destinato a soddisfare le esigenze di tutti

i settori industriali. Idealmente, esso dovrebbe essere utilizzato come base per la

scrittura di norme piu specifiche (ad esempio, specifiche per settore e/o per appli-

cazione), ma e anche destinato ad essere utilizzato direttamente nei casi in cui queste

non esistano.

2.2.1.1 Struttura

Si tratta di un documento di grandi dimensioni, di circa 400 pagine in totale,

diviso in sette parti.

Parte 1 requisiti generali;

Parte 2 requisiti per E/E/PES relativi alla sicurezza;

Parte 3 requisiti per il software;

Parte 4 definizioni e abreviazioni;

3electrical/electronic/programmable electronic system

15

Page 34: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Parte 5 esempi di metodi per la determinazione del livello di integrita di sicurezza;

Parte 6 linee guida per l’applicazione della seconda e terza parte;

Parte 7 panoramica su tecniche e misure.

2.2.1.2 Concetti

Lo IEC 61508 basa i suoi approcci su certo numero di concetti fondamentali:

1. un modello molto dettagliato del ciclo di vita del sistema;

2. la nozione di sicurezza funzionale: lo standard richiede la fornitura di funzioni,

dette, di sicurezza per mitigare il rischio associato con le funzioni del sistema

nei casi in cui tale rischio e considerato troppo alto;

3. la focalizzazione sulla riduzione del rischio: lo standard implicitamente assume

che non c’e nulla a rischio nullo, per il fatto che questo non puo essere mai

completamente eliminato;

4. la classificazione delle tipologie di sistemi e sottosistemi in quattro categorie:

EUC, EUCCS, SRS (Safety-Related Systems) e sistemi che non rientrano nelle

tre precedenti categorie;

5. la nozione di livello di integrita di sicurezza (SIL4) di una funzione richi-

esta: sono previste quattro livelli, dal SIL1 al SIL45, ovvero da integrita

moderatamente stringente a molto stringente.

E’ importante capire, inoltre, che tutti i sistemi sono considerati dallo stan-

dard come ‘sistemi instrumentati per la sicurezza’ (SIS6). Da questa osservazione ne

consegue che sono sempre presenti due sottosistemi, ovvero:

• l’apprecchiatura sotto controllo (EUC7): e il sottosistema composto dall’ap-

parecchiatura che fornisce alcune o tutte le funzioni per cui il sistema e stato

sviluppato;

4Safety Integrity Level5il SIL0 corrisponde a nessun bisogno di sicurezza6Safety Instrumented System7Equipment under Control

16

Page 35: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

• il sistema di controllo del EUC (EUCCS8): e il sistema di controllo dell’ap-

parecchiatura. Esso risponde ai segnali di input che arrivano dal processo e/o

dall’operatore e genera segnali di output che portano il EUC a lavorare nel

modo desiderato.

La figura 2.8 schematizza le relazioni tra EUC, EUCCS e sistema di protezione.

L’esempio pratico di un EUCCS e mostrato in figura 2.9. Lo schema evidenzia i tre

Figura 2.8: EUC e relativo sistema di controllo

Figura 2.9: esempio di EUCCS (del SIS)

componenti principali:

S sensore: controlla l’evoluzione dei parametri chimico-fisici che rappresentano

le prestazioni dei processi (temperatura, pressione, flusso, livello, etc.). Se

almeno uno di questi parametri supera un livello prefissato, e vi rimane, questo

8EUC Control System

17

Page 36: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

costituisce una deviazione dal normale funzionamento del EUC. In questo caso

viene inviato un segnale al sottosistema LS;

LS solutore logico: e un insieme di elementi logici che svolgono il processo deci-

sionale che si completa con l’attivazione del livello FE. Il solutore puo essere

un PLC9 o un micro-computer industriale dotato di software specifico;

FE elemento finale: e un elemento attivo che agisce direttamente (ad esempio

una valvola di arresto di emergenza) o indirettamente (una elettrovalvola) per

neutralizzare il comportamento anormale del processo, generalmente tramite

fermando il sistema per un periodo di tempo specifico per ogni funzione di

sicurezza.

2.2.1.3 Ciclo di vita della sicurezza

Il ciclo di vita globale della sicurezza (vedi figura 2.10) e fondamentale nello IEC

61508. Non solo offre un modello degli stadi della gestione di sicurezza nella vita di

un sistema, ma costituisce anche la struttura su cui la norma stessa si basa. Oltre-

tutto, lo standard indica i requisiti tecnici secondo l’ordine definito dalle fasi del

ciclo di vita. Lo scopo del ciclo di vita globale della sicurezza e quello di affrontare i

problemi della sicurezza funzionale in modo indipendente, superando cosı il presup-

posto che l’affidabilita funzionale produce automaticamente la sicurezza. Quindi,

indicando dei requisiti di sicurezza, distinti da quelli funzionali, permette loro di

essere convalidati indipendente, dando cosı maggiore fiducia in tutte le condizioni

operative e di fallimento. Il paradosso, tuttavia, e che le funzioni di sicurezza non

deve essere pensate come scollegate dal resto del progetto o delle attivita operative.

Esse hanno bisogno di essere integrate in una prospettiva complessiva del sistema in

ogni fase del ciclo di vita.

Nel ciclo di vita della sicurezza globale, le Fasi 1 e 2, indicano la necessita di

considerare le implicazioni per la sicurezza dello EUC e del suo sistema di controllo

quando il progetto viene concepito. Nella fase 3, sono identificati i rischi, analizzati e

valutati sulla base di criteri di tollerabilita. Nella fase 4, i requisiti di sicurezza per le

misure di riduzione del rischio sono specificati, e nella fase 5 essi sono tradotti nella

progettazione delle funzioni di sicurezza, che sono attuate in sistemi di sicurezza, a

seconda della modalita selezionata di attuazione, nelle fasi 9, 10 e 11.

9controller logico programmabile

18

Page 37: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Figura 2.10: Ciclo di vita della sicurezza

19

Page 38: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Una volta pianificate le funzioni di sicurezza, una richiesta di modifica non puo

essere pianificata senza considerare il contesto di sicurezza globale, e questo si riflette

nelle fasi 6, 7 e 8.

Le operazioni di installazione e messa in opera, la convalida della sicurezza e del

funzionamento, e la manutenzione, sono considerate nelle fasi 12, 13 e 14.

Le fasi 15 e 16 coprono la modifica, l’ammodernamento e la disattivazione,

rispettivamente, del sistema.

La fase 9 del ciclo di vita viene successivamente dettagliato, pur rimanendo gen-

erale, in: sviluppo del hardware (vedere figura 2.11) e sviluppo del relativo software

(vedere figura 2.12).

Figura 2.11: Ciclo di vita del hardware

Questi due cicli di vita imitano, in forma ridotta e semeplificata, il ciclo di vita

complessivo. Essi sottolineano che, insieme con lo sviluppo, devono essere espletati

compiti specifici per pianificare ed eseguire la convalida delle proprieta di sicurezza

del sistema o sottosistema. Siccome questo ciclo di vita e destinato ad applicarsi

sia ai sottosistemi che al sistema completo, l’integrazione del sottosistema con altre

parti del sistema e rappresentato in modo esplicito.

20

Page 39: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Figura 2.12: Ciclo di vita del software

Nel caso del software, l’attivita di integrazione comprende le attivita di ‘integrare’

il software con l’hardware, cioe di ottenere il codice in esecuzione sul dispositivo

target.

2.2.1.4 Safety Integration Level

Lo IEC 61508 specifica quattro livelli di prestazioni per una funzione di sicurezza

di un sistema. Questi sono chiamati safety integrity level (SIL). Il SIL1 e il piu basso

livello di integrita di sicurezza ed il SIL4 e il piu alto livello.

Lo standard specifica in modo dettaglaito i requisiti necessari per raggiungere

ogni livello. Tali requisiti sono piu rigoroso a piu elevati all’aumentare del SIL, al

fine di ottenere la probabilita di guasto pericoloso quanto piu bassa possibile.

Un E/E/PES legato alla sicurezza, in genere, implementa piu di una funzione

di sicurezza. Se i requisiti di integrita di sicurezza per queste funzioni sono diversi,

allora i requisiti richiesti per il SIL piu elevato si applicano all’intero sistema, a meno

che non vi sia una sufficiente indipendenza di attuazione tra di esse.

Se un singolo sistema E/E/PE e in grado di fornire tutte le funzioni di sicurezza

richieste, e l’integrita richiesta e inferiore a quella indicata per SIL1, lo IEC 61508

non si applica.

21

Page 40: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

2.2.2 Il modello concettuale

L’obiettivo e quello di caratterizzare le informazioni utilizzate e quelle sviluppate

dall’applicazione del ciclo di vita del software di sicurezza secondo lo IEC 61508.

Sebbene ci si concentra principalmente sul software, occorre riconoscere la stretta

relazione tra con l’hardware in un sistema ad elettronica programmabile10. In parti-

colare, l’architettura ed i requisiti di sicurezza hardware costituiscono una parte im-

portante della catena di prove per il software, e sono strettamente connessi alle speci-

fiche di sicurezza del software ed all’attivita di integrazione con l’hardware. Quindi,

nel modello, si colgono i requisiti e la decomposizione non solo dell’architettura del

software, ma anche dell’hardware.

I concetti del modello sono stati suddivisi in dieci gruppi (pacchetti), vale a dire:

i concetti legati al sistema, i pericoli, i requisiti, i concetti di processo, gli artefatti,

le linee guida, le motivazione, la gestione della configurazione, i problemi e i concetti

specifici del dominio. Tutta la complessita dello standard IEC 61508 si riversa nel

modello concettuale. Questo rende difficoltosa la visualizzazione dell’intero modello,

riportato in figura 2.13.

Dato il carattere generico di IEC 61508, tale modello concettuale e destinato ad

essere specializzato in contesti specifici di sicurezza in cui deve essere raggiunta la

certificazione del prodotto.

2.2.2.1 System Concepts

Descrive gli elementi di base necessari per concettualizzare i sistemi di controllo

relativi alla sicurezza che coinvolgono sia hardware che software.

Un PES e un blocco composto da uno o piu blocchi hardware e controllata da

un certo numero di blocchi software. Un blocco hardware puo rappresentare un

entita meccanica, elettrica o elettronica, sia programmabile che non programmabili.

Entrambi i blocchi hardware e software possono essere gerarchicamente scomposti

in blocchi di livello inferiore. Per il software, i tipici livelli di decomposizione sono:

modulo, componente, sottosistema e sistema. I collegamenti tra i blocchi e gli arte-

fatti di sviluppo corrispondenti sono colti attraverso l’associazione tra i concetti di

blocco e artifatto. Le interazioni tra i blocchi sono espressi come interfacce. Rendere

le interfacce esplicita e necessario per ridurre al minimo gli squilibri e le situazioni

di stallo durante l’integrazione.

10di seguito abbreviato in PES

22

Page 41: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Figura 2.13: Il modello concettuale completo

23

Page 42: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Figura 2.14: System concepts

2.2.2.2 Hazard Concepts

Figura 2.15: Hazard Concepts

Cattura i concetti di pericolo e di rischio ad esso associato, che poi sono il

fondamento per i requisiti di sicurezza e per il SIL.

Un pericolo e relazionato a:

• un elemento di rischio posseduto dal sistema;

• un meccanismo di avvio, costituito da un evento;

• un rischio.

24

Page 43: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Il rischio e il periocolo hanno due relazione:

• la pertinenza con un artefatto;

• la derivazione da un requisito di sicurezza.

2.2.2.3 Requirements Concepts

Figura 2.16: Requirements Concepts

Un requisito e una frase che identifica una capacita, una caratteristica o un

fattore qualitativo del sistema tale da avere un qualche valore per l’utente11.

Il concetto di requisito e originato da una sorgente che puo essere:

• uno standard;

• una pratica raccomandata;

• un agente del processo (utente).

Il requisito inoltre si puo applicare ad una modalita operativa. Quest’ultima e

composta da uno stato sicuro o insicuro.

Il requisito puo essere di safety. In questo caso esso e assegnato al concetto di

SIL.11nell’accezione di stakeholder

25

Page 44: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

2.2.2.4 Process Concepts

Figura 2.17: Process Concepts

In questo package la nozione centrale e quella di attivita. Essa rappresenta una

funzionalita con specifico input ed output (due relazioni con gli artefatti). L’attivita

e scomponibile in sotto-attivita e diverse attivita componengo una fase del ciclo di

vita. Inoltre, una attivita e svolta ad un agente, che puo essere una organizzazine

o un individuo. In quest’ultimo caso l’attivita richiede delle competenze possedute

dall’individuo. L’attivita inoltre usa delle tecniche, relazione con in SIL tramite le

raccomandazioni.

2.2.2.5 Artifact Concepts

Gli artefatti, caratterizzati da una tipologia, possono essere (specializzati in):

• report;

• descrizione;

• specifica;

• piano;

• lista;

• log;

• istruzione;

• diagramma;

26

Page 45: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Figura 2.18: Artifact Concepts

• richiesta.

Vari artefatti sono relazioni tramite link (ad esempio un diagramma in un report).

2.2.2.6 Issue Concepts

Figura 2.19: Issue Concepts

Problema e il termine generale che usiamo per indicare una situazione che deve

essere risolta per quanto riguarda un elemento di controllo o di un requisito. I prob-

lemi possono rappresentare difetti, errori umani ed enhancement e possono essere

27

Page 46: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

il risultato di attivita di verifica e validazione (ad esempio test e controllo) e valu-

tazione della sicurezza. Inoltre, gli enhancement possono essere proposti a diversi

stadi dello sviluppo, come risultato di attivita come l’ingegneria dei requisiti e la pro-

gettazione, o in risposta alle conclusioni della verifica&validazione e la valutazione

della sicurezza.

I difetti possono essere ulteriormente raffinata in errori, fallimenti e guasti. Un

errore e una discrepanza tra il reale e l’uscita ideale. IEC 61508 distingue gli errori

di sistema dagli errori umani, denominati sbagli. Gli sbagli denotano risultati im-

previsti a causa di un’azione umana o per l’inazione. Un fallimento e definito come

l’incapacita di una unita ad eseguire una funzione richiesta. Infine, un difetto e una

condizione anormale che causa un guasto del gruppo (ad esempio, un bug software).

2.2.2.7 Configuration Management Concepts

Figura 2.20: Configuration Management Concepts

Quesot package raccoglie i concetti richiesti per la gestione dei cambiamenti e

per assicurare che i requisiti di sicurezza continuino ad essere soddisfatti man mano

che il sistema evolve. Dimostrare l’accuratezza della gestione dei cambiamenti e

necessario per la conformita con la IEC 61508.

Il concetto centrale e l’elemento sotto controllo, ovvvero qualunque oggetto per

cui un cambiamento significativo possa essere documentato. In questo modello,

i blocchi, il sistema e gli artefatti sono elementi sotto controllo. Ognuno di tali

elementi puo avere qualche fonamento logico che ne giustifica l’esistenza, e assunzioni

che descrivono le condizioni e i vincoli che riguardamo gli elementi.

28

Page 47: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

2.2.2.8 Justification Concepts

Figura 2.21: Justification Concepts

Lo sviluppo del sistema comporta vari decisioni che hanno bisogno di essere

giustigicate da fondamenti logici e basate su assunzioni riguardanti il dominio e gli

artefatti. Una assunzione e una premessa che non e sotto il controllo del sistema. Il

fondamento logico e la ragione che spiega l’esistenza di un elemento sotto controllo.

Il fondamento puo essere supportato da una o piu assunzioni.

2.2.2.9 Guidance Concepts

Figura 2.22: Guidance Concepts

Molti aspetti dello sviluppo sono influenzati dalle regole di risorse esterne. Questo

package descrive le varie sorgenti di consigli e raccomandazioni usate durante lo

sviluppo: standard e pratiche consigliate. Gli standard si specificano in standard

generici e standard specifici del settore.

2.2.2.10 Domain-specific Concepts

Raccoglie alcune enumerazioni che possono essere personalizzate definendo valori

specifici di un dato contesto.

29

Page 48: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

2.2.2.11 Lifecycle Activity Concepts

In questo package vengono descritte le attivita del ciclo di vita per il software

della figura 2.12.

Cattura dei requisiti Definisce il concetto di ingegneria dei requisiti, come es-

tensione del concetto di attvita, di requisito di sicurezza del sistema e requisito di

sicurezza del software, come estensione del concetto di specifica. L’ingegneria dei

requisiti prende in input i requisiti di sistema e produce in output i requisiti software.

Pianificazione della validazione Definisce l’attivita di verifica del software. Es-

sa prende in input la specifica dei requisiti di sicurezza e produce artefatto, detto

piano di validazione del software.

Disegno e sviluppo Descrive sette sotto-attivita:

• sviluppo dell’architettura;

• standard di codifica e strumenti di supporto;

• disegno del software;

• disegno dei moduli software;

• implementazione del codice sorgente;

• testing dei moduli software;

• testing dell’integrazione dei moduli.

Integrazione dell’elettronica programmabile Riguarda l’integrazione del soft-

ware nei componenti elettronici dell’hardware per assicurare che la loro conbinazione

sia compatibile con i requisiti di sicurezza.

Funzionamento e modifica Lo scopo di questa fase e fornire informazioni e

procedure, riguardanti il software, necessarie per assicurare il corretto funzionamento

del sistema durante il suo funzionamento e durante la modifica.

Validazione Assicura che il sistema risultante dall’integrazione soddisfi i requisiti

per la sicurezza in relazione al SIL.

30

Page 49: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

Attivita trasversali Riguarda la modifica, verifica, valutazione della sicurezza.

Queste tre attivita possono influenzare tutte le fasi del ciclo di vita del software.

2.3 Motivazioni al lavoro di tesi

Lo standard IEC-61508 fornisce la metodologia generica del ciclo di vita per la

produzione di ogni SIS e, generalmente, e considerato lo standard generico migliore

disponibile per la gestione della sicurezza funzionale nel software, ma, allo stesso

modo e anche largamente considerato come difficoltoso da usare e costoso da imple-

mentare [Tim02, Red00, Dea09]. L’interpretazione pratica dello standard e spesso

percepita come complicata ma con con le linee guida appropriate, ed una certa quan-

tita di training, gli ingegneri si trovano presto bene nell’usare le metodologie e con

i principi del ciclo di vita.

In assenza delle adeguate competenze e di esperienza, l’applicazione della IEC61508

puo risultare scoraggiante. Lo standard pero fornisce una opportunita per soddisfare

le necessita industriali in fatto di qualita. Cio permette un risparmio significativo,

sia in termini di costo del prodotto, sia in termini di incidenti evitati.

Per compensare le difficolta appena evidenziate, Clive Timms12 suggerisce [Tim02]

che l’utilizzazione di strumenti software di supporto e essenziale per applicare in

modo efficiente lo standard, per la gestione dell’intero ciclo di vita del SIS.

Sempre piu spesso, gli organismi di regolamentazione richiedono, ai produttori di

sistemi software-intensive critici per la sicurezza, di fornire evidenze oggettive (nella

forma di un safety-case) per dimostrare che gli elementi software di un sistema sono

sufficientemente sicuri.Le ricerche esistenti a riguardo del safety-case si sono focal-

izzate su come costruire le argomentazioni basandosi sulle evidenze disponibili, ma

poco e stato fatto per caratterizzare precisamente che cosa puo essere una evidenza.

Di conseguenza, i produttori di sistemi sono lasciati praticamente senza indicazioni

su quali prove raccogliere durante lo sviluppo del software. Questo ha portato i

team di sviluppo a dover recuperare le evidenze dopo la conclusione dello sviluppo

del sistema: questo e un compito estremamente costoso e talvolta impraticabile.

La IEC 61508 fornisce alcune indicazioni per la raccolta di informazioni relative

alla sicurezza ed alla certificazione. Questo orientamento e prevalentemente testuale,

non e espresso in una forma precisa e strutturata, e non e facile specializzarsi ai

bisogni specifici del contesto. Per affrontare questi problemi, e stato presentato un

12attualmente direttore di C&C Technical Support Services Ltd, ha una esperienza di 38 anninel settore Exploration And Production di SHELL (UK)

31

Page 50: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 2. INTRODUZIONE

modello concettuale generico per caratterizzare gli elementi di prova e facilitare cosı

la certificazione.

Un problema tipico dei produttori e che non sempre e chiaro quali documenti,

e a quale livello di dettaglio, essi dovrebbero fornire a sostegno della sicurezza.

Inoltre, e spesso poco chiaro quello che dovrebbe essere l’ambito di ogni documento,

e come questi documenti dovrebbero essere collegati ai, i requisiti, le attivita e cosı

via. Questi problemi in genere scaturiscono in diverse iterazioni inutili per affinare

e completare i documenti di certificazione, come pure molti malintesi che avrebbe

potuto essere evitati.

La tematica affrontata da questa tesi e lo studio del processo che porta alla

definizione di un accordo tra produttore e certificatore sulle evidenze da fornire per

la certificazione di standard di qualita. Viene inoltre presentato uno strumento

software a supporto del processo che consenta:

• al produttore di comprendere meglio lo standard e di conoscere a priori gli ele-

menti di prova e i documenti da collezionare durante lo sviluppo del prodotto;

• al certificatore di trasmettere le proprie aspettative e ottenere documenti con

struttura e contenuti adeguati

32

Page 51: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

Capitolo 3Definizione del processo e

strumento a supporto

‘Program testing can be used to

show the presence of bugs, but

never to show their absence!’

Edsger Dijkstra, Structured

Programming, 1972

3.1 Elementi di base e visione d’insieme

3.1.1 Il processo di certificazione

Il processo di certificazione si divide in tre fasi principali:

1. sottomissione della domanda di certificazione ad un Organismo di Controllo;

2. una serie di incontri fra il team di revisione ed il produttore ;

3. concessione della certificazione e sorveglianza.

Questa sequenza e dettagliata in figura 3.1.

Nella prima fase, l’azienda raccoglie numerose informazioni di vari tipi, ad es-

empio a riguardo dell’organizzazione aziendale, oppure al prodotto o al processo

da certificare. Successivamente viene scelto un Organismo di Controllo (OdC), fra

quelli autorizzati dall’Organismo di Accreditamento (OdA), e viene presentata una

33

Page 52: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.1: diagramma a blocchi del processo (da sostituire con un BPEL)

34

Page 53: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

richiesta di certificazione. L’OdC visiona la richiesta ed il materiale allegato e molto

spesso chiede all’azienda altre informazioni. Alla conclusione di questa fase l’OdC

puo rigettare la richiesta, terminando il processo, oppure accettarla. In questo caso

viene assegnato all’azienda richiedente un team di certificazione ed un responsabile.

Nella seconda fase il team di certificazione controlla la documentazione fornita

dall’azienda, ad esempio per valutare la maturita dell’azienda, e fissa un incontro

preliminare per pianificare il processo di certificazione. Successivamente il team di

certificazione visita diverse volte il cliente, ad esempio per presenziare ai test del

prodotto da certificare, oppure per ispezionare la documentazione di progetto. Ogni

incontro produce un report in cui sono evidenziate quali requisiti dello standard

di qualita non sono stati ritenuti soddisfacenti. Viene quindi chiesto all’azienda di

apportare delle modifiche e delle correzioni al prodotto.

La terza fase inizia quando tutti i requisiti dello standard sono soddisfatti ed il

team produce una raccomandazione per l’assegnazione della certificazione.

3.1.2 Il problema

Il modello concettuale presentato nel capitolo precedente puo essere completa-

mente specializzato per un particolare contesto e, successivamente, usato per aiutare

i produttori del sistema nell’attivita di raccolta degli elementi di prova rilevanti,

necessari per la successiva certificazione. Ad ogni modo, per avviare tale processo,

occorrono delle consultazioni iniziali al fine di definire alcuni parametri essenziali

per la specializzazione del modello. La collaborazione pero richiede la compresenza

delle due parti e questo non e sempre possibile.

L’attivita di certificazione di un sistema, inoltre, incontra spesso diverse prob-

lematiche intrinseche:

• le giuste competenze diventano disponibili tardivamente, quando esse non hanno

molta utilita;

• le evidenze non sono strutturate e collegate; una loro revisione risulta quindi

molto difficoltosa;

• il produttore non raccoglie tutti i dati che sono necessari;

• incomprensioni generate dall’assenza di un vocabolario comune;

• il produttore puo fare scelte incompatibili fra loro, rispetto allo standard di

qualita;

35

Page 54: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

• un documento ufficiale (firmato) deve essere mantenuto a mano;

• non e semplice monitorare i progressi e lo stato di completamento.

Questi problemi coinvolgono, allo stesso modo, sia il certificatore che il produttore

del sistema. L’impatto risulta nella difficolta di capire in dettaglio lo standard e il

modello concettuale.

Una soluzione soddisfacente dovrebbe supportare la collaborazione tra produt-

tore e certificare per arrivare ad un accordo in merito a quali evidenze debbano essere

fornite per soddisfare lo standard di qualita. Cio andrebbe espletato offrendo la pos-

sibilita di erogare un questionario, basato sullo standard, le cui risposte, date dal

produttore, e convalidate dal certificatore, andranno a formare la base per la special-

izzazione del modello. Le parti coinvolte dovrebbero avere la possibilita di firmare

un accordo, formale o informale, concernente cio che e richiesto al produttore.

3.1.3 La soluzione proposta

Dal punto vista generale una soluzione appropriata dovrebbe:

1. distingue tre categorie di utenti:

(a) administrator: si occupa del setup del sistema;

(b) supplier: si occupa della specializzazione del modello concettuale;

(c) certifier: si occupa di ratificare le proposte del supplier;

2. assumere in input:

(a) un modello concettuale rappresentante uno standard di qualita;

(b) un questionario, basato sul modello concettuale;

(c) una lista di deliverables;

3. produce in output:

(a) un contratto che supplier e certifier possono firmare.

Per quanto riguarda le funzionalita, il sistema dovrebbe permettere:

1. all’amministratore la definizione del modello concettuale tramite l’upload di uno

o piu file;

36

Page 55: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

2. all’amministratore la definizione del questionario relativamente ad un certo mod-

ello concettuale:

(a) definizione delle domande del questionario;

(b) definizione dell’entita che la domanda va a specificare;

(c) definizione delle alternative per ogni domanda;

(d) dovrebbe essere possibile definire quali alternative si escludono vicende-

volmente;

(e) definizione di domande di contesto e delle meta-domande;

3. all’amministratore la creazione di nuovi contratti (instanziazione del modello

concettuale);

4. all’amministratore la definizione delle utenze, ovvero:

(a) la creazione di utenti;

(b) l’assegnazione di ruoli relativi ai contratti;

5. all’amministratore la definizione delle categorie e delle sotto-categorie dei deliv-

erables;

6. all’amministratore la definizione dei deliverables di default;

7. a supplier e certifier la produzione di documenti riepilogativi delle status del

questionario, ovvero;

(a) la proposta di nuovi documenti;

(b) l’approvazione, disapprovazione e cancellazione dei documenti;

8. al supplier la definizione dei deliverables relativi al particolare contratto;

9. al supplier la proposta delle evidenze da fornire tramite il riempimento del ques-

tionario;

10. al supplier la proposta del contenuto dei deliverables;

11. al certifier l’approvazione delle evidenze;

12. al certifier l’approvazione dei deliverables;

13. a tutti gli utenti di monitorare lo stato di avanzamento tramite grafici o altri

strumenti equivalenti:

37

Page 56: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

(a) livello di copertura del questionario rispetto al modello concettuale;

(b) distribuzione dello status di approvazione delle evidenze;

(c) distribuzione dello status di approvazione dei deliverables;

14. il mantenimento lo storico delle operazioni di proposta e approvazione delle

evidenze e dei deliverable;

15. al supplier e al certifier di produrre e visionare la documentazione;

16. al supplier e al certifier di approvare e ritirare la documentazione;

17. mantenere lo storico delle operazioni di proposta e approvazione della documen-

tazione.

Il sistema, inoltre, dovrebbe soddisfare i seguenti vincoli:

• di interfaccia

– verso gli utenti: il sistema si deve presentare come una applicazione client-

server di tipo web;

– verso altri sistemi: il sistema deve interpretare modelli concettuali pre-

sentati come diagrammi UML di tipo class-diagram in formato ECORE;

• di usabilita

– sebbene sia rivolto anche a persone che cercano lavoro nel campo dell’In-

formation Technology, dai quali ci si aspetterebbe un livello di competenza

superiore alla media, l’interazione con il sistema non deve presentare un

elevato grado di complessita e deve essere fruibile da un pubblico quanto

piu eterogeneo possibile;

• di affidabilita

– il sistema deve poter mantenere i propri dati anche in caso di guasti

(problemi di fornitura elettrica, usura dell’hardware del server, attacchi

informatici);

– deve essere possibile pianificare dei backup periodici del database;

– in caso di guasto, un riavvio del sistema e tollerabile, data la natura

non-mission critical;

• di prestazioni

38

Page 57: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

– deve permettere l’accesso simultaneo di un numero indefinito di utenti,

anche sullo stesso contratto;

– il tempo massimo di risposta deve rimanere inferiore ai 30 secondi. Tale

valore dipende strettamente dalla natura web del sistema: un utente,

passato tale lasso di tempo, percepisce il sistema come bloccato, non

avendo alcun riscontro sull’elaborazione in corso;

• di sicurezza

– il sistema deve prevenire l’accesso ad utenti non autorizzati;

– il sistema deve prevenire la perdita di informazioni.

3.1.4 Oggetti del dominio del problema

A partire dai requisiti precedenti, ho estrapolato un modello concettuale degli

oggetti/concetti del dominio del problema. La figura 3.2 mostra i concetti e le

relazioni che intercorrono fra essi.

3.1.4.1 Modello concettuale dello standard di qualita

Il modello concettuale (nel diagramma e indicato come ‘UML model’) e una

astrazione dello standard di qualita che mette in evidenza tutti i concetti espliciti

ed impliciti dello standard.

Il modello si presenta nella forma di un diagramma delle classi, quindi:

• un ‘modello’ e composto di ‘package’;

• ogni ‘package’ puo contenere altri ‘package’, secondo una relazione padre-figli;

• ogni ‘package’ contiene un certo numero di classi;

• ogni ‘classe’ puo essere estesa da altre, da cui la relazione padre-figli;

• una classe puo essere composta di ‘campi’;

• una ‘relazione’ lega due classi tramite uno o due campi (per le relazioni d’uso)

e, opzionalmente, una classe di associazione.

39

Page 58: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.2: Oggetti del dominio del problema

40

Page 59: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

3.1.4.2 Questionario

Un ‘questionario’ e essenzialmente una collezione di ‘domande’, le quali, a loro

volta, sono una collezione di alternative. Il questionario fa uso di un ‘modello

concettuale’, mentre le ‘domande’, hanno un riferimento alle ‘classi’ oppure alle

‘relazioni’.

Domande relative a concetti Una domanda puo riferirsi ad un concetto oppure

ad una relazione fra concetti. Nel primo caso la domanda ha lo scopo di definire

le evidenze che possono specificare il concetto del modello, relative al contesto am-

bientale e aziendale del produttore. Nel modello, la ‘domanda’ e riferita ad una

‘classe’.

Le domande relative a concetti possono essere a risposta aperta oppure no. Se

non sono a risposta aperta una domanda e costituita da un insieme di ‘alternative’

che l’utente seleziona in base alle sue scelte.

Un esempio e: quali tecniche vengono usate per l’analisi statica?. La domanda e

relativa al concetto ‘Tecnica’, del package ‘Process concepts’, e le alternative definite

sono:

• Boundary value analysis

• Checklists

• Control flow analysis

• Data flow analysis

• Error guessing

• Fagan inspections

• Sneak circuit analysis

• Symbolic execution

• Walk-throughs/design reviews.

41

Page 60: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Domande relative alle relazioni fra concetti Questo tipo di domande servono

per specificare le relazioni fra i concetti. Al contrario del caso precedente, la domanda

si riferisce ad una ‘relazione’ del modello.

Un esempio e il seguente: occorre specificare la relazione ‘is made up of’ fra i

concetti di Event e InitiatingMechanism. L’utente provvede a collegare evidenze

di tipo ‘Evento’, ad esempio ‘incendio’, con quelle di tipo ‘meccanismo di avvio’,

come ‘corto circuito’ oppure ‘alta temperatura’.

Domande di contesto Le domande di contesto estendono la domanda e ne rap-

presentano un caso particolare: questo genere di domande sono indipendenti dalle

classi del modello concettuale, per questo fanno riferimento ad una meta-classe ag-

giuntiva rispetto al modello. Lo scopo delle domande di contesto e quello di creare

una prima personalizzazione del questionario.

Alcuni esempi di domande di contesto sono:

• in quale Paese il prodotto sara venduto?

• quanti sono i componenti del team di sviluppo?

• qual’e la dimensione della vostra azienda (in termini di dipendenti e collabo-

ratori totali)?

Meta-domanda del SIL Un altro caso particolare di domanda e quella che

richiede di specificare il SIL da raggiungere. Anche questa domanda fa riferimento

ad una meta-classe aggiuntiva rispetto al modello. Sebbene nel metamodello dello

standard IEC-61508 sia previsto il concetto di SIL, questa scelta consente di gestire

anche altri standard di organismi diversi da IEC.

3.1.4.3 Regole di esclusione e di molteplicita

Una regola di esclusione lega due alternative che non possono essere contempo-

raneamente date come risposta: quando una delle due e compresa in una risposta,

l’altra deve essere bloccata. Una regola di molteplicita, invece, lega una alternativa

ad una domanda: quando l’alternativa e compresa in una risposta, la molteplicita

richiesta per una domanda cambia.

42

Page 61: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

3.1.4.4 Ruoli utente

L’utente e un concetto centrale nel modello del sistema, specialmente per quanto

riguarda il mantenimento dello storico delle operazioni. Inoltre, ogni utente e re-

lazionato con un contratto tramite un ruolo. I ruoli previsti sono: amministratore

del contratto, produttore del software e certificatore.

3.1.4.5 Accordo tra le parti

L’accordo fa riferimento ad un questionario ed e una composizione dalle risposte

date al questionario stesso, ovvero le evidenze. Esso, inoltre raccoglie i deliverables

definiti per l’accordo ed e composto dai documenti.

Evidenze Le evidenze le istanziazioni, per un particolare accordo, delle alternative

di tutte le domande del questionario. La risposta, in questo senso, e la composizione

di tutte le evidenze che fanno riferimento ad alternative della stessa domanda. Essa

e anche relazionata con l’utente tramite uno storico.

Le evidenze possono essere, come detto in precedenza, ‘incendio’, ‘corto circuito’

e ‘Data flow analysis’, ma anche ‘Test case execution from error guessing’ oppure

‘Equivalence classes and input partition testing’.

Deliverables I deliverables sono parte integrante dell’accordo: essi infatti dipen-

dono strettamente dall’organizzazione dell’azienda, dal processo di sviluppo adottato

nel progetto, dal tipo di prodotto e da molti altri fattori. Il numero dei deliverables

in un progetto spesso e molto elevato ed e difficile gestirli: per tale motivo un deliver-

able e anche associato ad una sottocategoria di deliverables, a sua volta associata ad

una categoria di deliverables. Il deliverable e anche relazionato con l’utente tramite

uno storico.

Esempi tipici di deliverables sono quelli relativi al ciclo di vita del software, come:

• categoria G (safety)

– sottocategoria G010 (Risk analysis)

∗ Risk Management Plan

• categoria Z (multidisciple)

– sottocategoria Z250 (Procedure)

43

Page 62: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

∗ Change Control Plan

∗ Project Planning

– sottocategoria Z300 (Declaration)

∗ Feasibility Study

Documenti I documenti fanno parte di un accordo e sono relazioni con l’utente

tramite uno storico. L’esempio di un documento completo e presente in appendice.

3.2 Modello architetturale del sistema

L’architettura di massima del sistema e schematizzata in figura 3.3 in cui:

• il sistema e rappresentato dal box centrale;

• gli attori sono rappresentati in alto rispetto al sistema;

• gli input sono a sinistra;

• gli output sono a destra.

Gli attori fondamentali sono l’amministratore, il produttore ed il certificatore.

Mentre il primo si occupa del mantenimento e del setup del sistema, gli altri due

partecipano alla produzione di accordi.

3.2.1 Input

Gli oggetti in input al sistema i due file, ECORE ed ECORE-DIAG, che de-

scrivono il modello concettuale in modo sostanziale e grafico, rispettivamente.

3.2.2 Output

Il sistema puo produce in output il documento da firmare, ovvero l’accordo vero

e proprio che, successivamente, guidera le ispezioni dei verificatori e l’intero processo

di certificazione. Il documento include le informazioni riguarda le evidenze, i deliv-

erable e le relazioni tra le evidenze. Contiene, inoltre, i diagrammi di monitoraggio

dello stato di completamento, comprese due matrici per controllare deliverable senza

evidenze ed evidenze che non appaiono in nessun deliverable.

44

Page 63: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.3: Architettura dell’applicazione software

3.2.3 Sistema - rappresentazione dei dati

I dati su cui lavora il sistema sono, essenzialmente, il modello concettuale dello

standard di qualita ed il questionario. Il primo deriva dai file in input, mentre

il secondo deriva dalle attivita dell’amministratore. I due elementi, inoltre, sono

correlati dalla mappatura del questionario nel modello (rappresentato in figura da

una catena).

3.2.4 Sistema - componenti/interfacce verso l’esterno

Il sistema ha tre interfacce principali verso gli utenti, le quali consentono di: am-

ministrare/configurare il sistema, rispondere al questionario e approvare le proposte.

Sono inoltre presenti due interfacce verso l’input e l’output. Il modulo ‘XML

parser’ svolge le funzionalita che consentono di analizzare i file in ingresso e memo-

rizzarli nella rappresentazione interna del modello concettuale. Il modulo ‘Exporter’,

invece, prende dati dal questionario e dal modello e produce i documenti di output.

I moduli ‘rules checker’ e ‘monitor’, rivestono un ruolo molto importante, in

quanto sono quelli che si occupano, rispettivamente:

• di controllare la consistenza del questionario rispetto alle regole di molteplicita

e di esclusione fra le alternative selezionabili;

45

Page 64: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

• di produrre i diagrammi che consentono alle parti di controllare velocemente

lo stato di completamento

3.3 Flussi approvativi di un accordo fra produt-

tore e certificatore

Il produttore ed il certificatore raggiungono un accordo, a riguardo delle evi-

denze da fornire per iniziare l’iter di certificazione, tramite un processo iterativo di

proposizione e approvazione.

3.3.1 Approvazione delle evidenze da fornire

Figura 3.4: Diagramma a stati’iter approvativo delle evidenze

Le evidenze subiscono un workflow approvativo descritto in figura 3.4. In parti-

colare:

• quando il produttore risponde ad una domanda, lo stato iniziale della evidenza

e ‘proposta’;

• lo stato passa da ‘proposto’ a

– ‘disapporvato’, se il certificare non concorda con l’evidenza;

– ‘apporvato’, altrimenti;

• dallo stato ‘disapporvato’ si passa allo stato ‘proposta’ se il produttore cambia

le risposte al questionario;

46

Page 65: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

• ‘approvato’ e lo stato finale.

Figura 3.5: Diagramma a stati’iter approvativo delle domande

Analogamente alle evidenze, anche le domande subiscono l’approvazione: tale

soluzione considera la possibilita in cui, il certificatore, approva tutte le evidenze

per una certa domanda, ovvero per una entita del modello concettuale, ma il set

proposto non e comunque completo. In tale situazione, quindi, diventa necessario

poter specificare, a livello di domanda, l’approvazione. Il diagramma a stati di figura

3.5.

• La domanda, inizialmente, e nello ‘da specificare’, ovvero non e mai stata

fornita una risposta;

• quando il produttore fornisce una risposta, viene controllato il respetto della

molteplicita richiesta e:

– se la molteplicita e corretta si passa nello stato ‘in attesa di approvazione’;

– altrimenti si rimane nello stato ‘da specificare’;

• da ‘in attesa di approvazione’ si passa a ‘disapprovato’ se il certificatore non

approva almeno una delle evidenze per la domanda;

47

Page 66: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

• al contrario, se il certificatore approva tutte le evidenze, lo stato, in base alle

azioni del certificatore, puo diventare ‘approvato’, ‘approvato parzialmente’ o

‘disapprovato’

• dagli stati ‘approvato parzialmente’ o ‘disapprovato’ si torna allo allo stato ‘in

attesa di approvazione’ se il produttore cambia le risposte alla domanda;

• ‘approvato’ e lo stato finale.

3.3.2 Approvazione del contenuto dei deliverables

Per giungere ad un compromesso non e sufficiente soltanto accordarsi sulle ev-

idenze da fornire, ma anche sui deliverables che le contengono. Per questo motivo

le evidenze devono essere approvate anche per quanto riguarda i deliverables in cui

sono incluse. Lo schema e le regole di transizione sono le stesse per l’approvazione

delle evidenze da fornire, sia a livello di singola evidenza che di intera domanda.

3.3.3 Approvazione dei documenti

I documenti che l’applicazione deve generare sono dei veri e propri contratti che

le parti dell’accordo, ovvero produttore e certificatore, possono firmare. I documenti

possono essere personalizzati includendo diverse informazioni a vari livelli di det-

tagli. Inoltre ogni documento rappresenta una fotografia dello stato dell’accordo nel

momento in cui viene generato. E’ per queste due ragioni che anche i documenti

subiscono un processo di approvazione secondo lo schema in figura 3.6.

Il documento:

• puo essere proposto dal certificatore o dal produttore ed assume lo stato,

rispettivamente, ‘proposto dal certificatore’ oppure ‘proposto dal produttore’;

• il produttore puo approvare un documento nello stato ‘proposto dal certifica-

tore’, passando allo stato ‘approvato’;

• il certificatore puo approvare un documento nello stato ‘proposto dal produt-

tore’, passando allo stato ‘approvato’;

• sia il produttore che il certificatore possono disapprovare un documento nello

stato ‘proposto dal certificatore’, ovvero nello stato ‘proposto dal produttore’,

passando allo stato ‘disapprovato’;

48

Page 67: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.6: Diagramma a stati’iter approvativo dei documenti

• il produttore puo proporre la cancellazione di documenti nello stato ‘approva-

to’, facendoli passare allo stato ‘cancellazione proposta dal produttore’;

• il certificatore puo proporre la cancellazione di documenti nello stato ‘approva-

to’, facendoli passare allo stato ‘cancellazione proposta dal certificatore’;

• il produttore puo approvare la cancellazione di documenti nello stato ‘cancel-

lazione proposta dal certificatore’, facendoli passare allo stato ‘cancellato’;

• il certificatore puo approvare la cancellazione di documenti nello stato ‘cancel-

lazione proposta dal produttore’, facendoli passare allo stato ‘cancellato’;

• ‘disapprovato’ e ‘cancellato’ sono gli stati finali.

49

Page 68: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

3.4 Modello entita-relazioni

In base a quanto discusso fin ora, e stato estrapolato il diagramma E.R. mostrato

in figura 3.7. Il modello consta di 25 entita e 39 relazioni. Per poterlo analizzare

agevolmente e conveniente evidenziare i gruppi principali.

Figura 3.7: Diagramma entita-relazione

50

Page 69: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.8: Diagramma ER, meta-modello dello standard

3.4.1 Meta-modello dello standard, figura 3.8

• modello: e l’elemento centrale e raccoglie le informazioni del meta-modello,

ovvero il nome, la descrizione e la versione.

• package: e l’equivalente del concetto di package nel metamodello; a livello di

relazioni:

– il package appartiene ad un modello;

– il package puo appartenere un super-package;

• classe: memorizza le informazioni salienti del concetto di classe:

– il nome;

– il package;

– l’eventuale super-package;

• campo: rappresenta un attributo ed ha due relazione con la classe

51

Page 70: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

– la prima rappresenta la ‘proprietaria’ dell’attributo;

– la seconda rappresenta il tipo dell’attributo.

3.4.2 Questionario, figura 3.9

Figura 3.9: Diagramma ER, questionario

• questionario: e l’entita fondamentale nel gruppo, si riferisce ad un modello;

• domanda: contiene il testo della domanda, la molteplicita, alcune flag per

definirne la tipologia; si relazione con una classe del modello;

• alternativa: contiene il testo dell’alternativa ed il SIL minimo; per quanto

riguarda le relazioni:

– l’alternativa di secondo livello ha una alternativa padre;

– ogni alternativa si riferisce ad una domanda;

• regola di esclusione: relaziona due alternative che sono mutuamente esclusive;

52

Page 71: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

• regola di molteplicita: relaziona una alternativa ad una domanda, memorizza

il numero minimo e massimo di risposte sulla domanda target.

3.4.3 Organizzazioni, utenti e ruoli, figura 3.10

Figura 3.10: Diagramma ER, organizzazioni-utenti-ruoli

• organizzazione: memorizza i dati delle aziende che utilizzano il sistema, ovvero

il nome, il paese di appartenenza ed il tipo (software house oppure professional

certifier);

• utente: appartiene ad una organizzazione, viene memorizzato il nome, la

username e la password;

• ruolo: ha nome e descrizione;

• assegnazione: relazione l’utente e un ruolo con un accordo.

3.4.4 Accordo, figura 3.11

• accordo: contiene il nome dell’accordo e due relazioni con le organizzazioni,

una produttore e una certificatore;

• risposta (ad una domanda): e relazionata con la domanda e l’accordo, contiene

lo stato di approvazione (a livello di domanda) del verificatore;

53

Page 72: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.11: Diagramma ER, accordo

• evidenza: contiene una flag per l’inclusione, lo stato di approvazione dell’evi-

denza e dei deliverables; le relazioni sono:

– la risposta di cui fa parte;

– l’alternativa;

– l’utente che propone l’alternativa;

– l’utente che approva l’evidenza;

– l’utente che approva i deliverables;

54

Page 73: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

• deliverable: e relazionato con l’accordo e la categoria del deliverable, contiene

un nome e una descrizione;

• deliverable - evidenza: relaziona la evidenza ed il deliverable e contiene una

flag che indica se l’evidenza e inclusa o meno;

• documento: e relazionato con l’accordo di cui fa parte, contiene lo stato di

approvazione ed il nome del file sul sistema di storage.

3.4.4.1 Dati di storico, figura 3.12

Figura 3.12: Diagramma ER, dati di storico

Le tre tabelle di questo sottogruppo,

• storico delle evidenze,

• storico dei deliverables,

• storico dei documenti,

memorizzano informazioni a riguardo delle modifica sulle tre entita, in particolare:

l’utente che ha operato la modifica, il ruolo dell’utente (come testo), il tipo di

operazione, l’istante di modifica.

55

Page 74: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

3.5 Meccanismo di routing fra le domande del

questionario

Le regole di esclusione e molteplicita possono interagire pericolosamente tra di

loro e portare ad uno stato incoerente del questionario. In effetti, poiche il numero

di alternative per una domanda e limitato, si puo verificare che non sia possibile

soddisfare i vincoli di molteplicita di una domanda, a causa del fatto che troppe

alternative (della domanda corrente) sono escluse dalle risposte di altre domande.

L’utente che compila il questionario deve, quindi, essere guidato per evitare stati

incoerenti, ovvero, che si ritrovi impossibilitato, ad un certo punto, a rispondere

ad una domanda, perche tutte le alternative sono escluse. In altre parole e neces-

sario un meccanismo che suggerisce l’ordine appropriato delle domande: cio viene

si definisce routing. Le metodologie attuali per la costruzione e la somministrazione

di questionari prevedono principalmente due meccanismi di routing:

• statico: e definito a priori, prende in considerazione soltanto una tabella di

coppie del tipo ‘sorgente - destinazione’;

• dinamico: si basa su una domanda di partenza e su una lista di regole del tipo

‘sorgente - destinazione - condizione’.

Per quanto riguarda il nostro strumento abbiamo ritenuto che entrambi i mecca-

nismi fossero poco validi ed inadeguati. Abbiamo percio optato per un meccanismo

di routing dinamico non vincolante. Non esiste quindi una domanda principale e

l’utente non e obbligato a seguire la procedura secondo una procedura step-by-step.

Per implementare questo meccanismo abbiamo introdotto il concetto di priorita di-

namica di una domanda. Essa viene calcolata in fase di esecuzione, per ciascuna

domanda q, tramite l’equazione 3.1 di seguito.

Priorityq = M ∗ (K ∗∑

N RegoleAttive +∑

N RegolePotenziali)

N(3.1)

Per meglio comprendere la formula, e necessario definire lo status delle regole di

esclusione rispetto all’alternativa X:

• se nessuna delle alterantive X ed Y , collegate dalla regola, sono selezionate,

allora definiamo la regola ‘potenziale’;

56

Page 75: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

• se l’alternativa Y e selezionata, la regola e ‘attiva’ per l’alterantiva X, in

quanto la esclude;

• al contrario, se l’alternativa X e selezionata, allora la regola e ‘annullata’ per

X.

La formula considera soltanto le prime due categorie di regole e, in particolare:

• ‘N’ il numero di alternative di ‘q’;

• ‘M’ il numero di risposte minimo previsto dalla regola si molteplicita di ‘q’;

• ‘PotentialExclusionRules’ e il numero di regole ‘potenziali’ che insistono sulle

‘N’ alternative;

• ‘ActualExclusionRules’ e il numero di regole ‘attive’ che insistono sulle ‘N’

alternative;

• un fattore moltiplicativo ‘K’, che abbiamo fissato a 10, necessario per dare

maggior peso alle regole ‘attive’.

Il rounting e definito ordinando le domande secondo valori decrescenti di priorita.

In altre parole, le domande sono presentate all’utente secondo la loro probabilita di

avere le rispettive alternative esclusi.

Una volta che il fornitore risponde a una domanda, allora la priorita diventa

minima. La priorita delle altre domande, vengono aggiornata sulla base delle risposte

fornite, in quanto delle regole di esclusione ‘potenziali’ diventano ‘attive’.

3.6 Casi d’uso individuati

I casi d’uso individuati dall’analisi dei requisiti sono sommariamente schematiz-

zati in figura 3.13.

3.6.1 Gestione dei modelli concettuali

L’attore che attiva il caso d’uso e l’amministratore.

57

Page 76: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.13: Diagramma dei casi d’uso individuati

58

Page 77: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.14: Gestione dei modelli concettuali, flusso principale

59

Page 78: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.15: Lista modelli UML caricati

3.6.1.1 Flusso principale

1. L’utente accede al sistema per caricare un carica un modello.

2. Il sistema presenta la lista dei modelli precedentemente caricati (figura 3.15)

3. L’utente preme il pulsante ‘Aggiungi nuovo modello’.

4. L’utente inserisce la descrizione del modello (figura 3.16)

Figura 3.16: Inserimento della descrizione del modello

5. Il sistema presenta la maschera per il caricamento del file ECORE (figura 3.17)

6. L’utente, premendo il pulsante ‘Upload’, sceglie il file dal proprio computer

(figura 3.18)

7. Il sistema mostra il progresso di caricamento del file (figura 3.19) e mostra la

maschera per il caricamento del file ECORE-DIAG

8. L’utente gli ultimi tre passi per caricare il fiale del diagramma.

9. Il sistema analizza i due file caricati, registra il nuovo modello concettuale, e

torna alla lista dei modelli caricati che conterra il nuovo record (figura 3.20)

60

Page 79: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.17: Maschera per il caricamento del file

Figura 3.18: Scelta del file da caricare

Figura 3.19: Progresso di caricamento del file

61

Page 80: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.20: Lista modelli UML caricati (dopo l’inserimento)

3.6.2 Gestione dei questionari

L’attore che attiva il caso d’uso e l’amministratore.

3.6.2.1 Relazioni con altri casi d’uso

• Include ‘gestione dei modelli concettuali’

3.6.2.2 Flusso principale

1. L’utente accede al sistema per creare un questionario.

2. Il sistema presenta la lista dei questionari precedentemente creati

3. L’utente preme il pulsante ‘Aggiungi questionario’

4. L’utente inserisce i dati necessari (figura 3.22), ovvero:

• nome del questionario

• modello concettuale di riferimento

5. L’utente preme il pulsante ‘Salva’

6. Il sistema presenta la lista dei questionari

62

Page 81: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.21: Gestione dei questionari, flusso principale

Figura 3.22: Inserimento di un nuovo questionario

63

Page 82: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.23: Gestione dei questionari, creazione di una nuova domanda (flussoalternativo F1)

64

Page 83: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

3.6.2.3 Flusso alternativo F1 - creazione di una nuova domanda di un

questionario

1. L’utente, dopo il passo 2 del flusso base, seleziona uno questionari preesistenti

dalla lista

2. Il sistema presenta una maschera di dettaglio del questionario selezionato

(figura 3.24)

Figura 3.24: Dettaglio di un questionario

3. L’utente clicca il pulsante ‘Lista domande’

4. Il sistema presenta la lista delle domande corredata da due grafici a torta che

indicano la copertura del modello concettuale a livello di packages e a livello

di classi (figura 3.25)

5. L’utente preme il pulsante ‘Aggiungi domanda’

6. L’utente inserisce i dati necessari (figura 3.26), ovvero:

• testo della domanda

• molteplicita

• numero minimo e massimo di risposte per le domande a risposta multipla

65

Page 84: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.25: Lista domanda di un questionario e torte della copertura del modello

66

Page 85: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.26: Creazione di una domanda

• domanda dipendente dal SIL

• domanda di contesto

• domanda a rispsota aperta

• package del modello concettuale a cui si riferisce la domanda (tranne per

le domande di contesto)

• classe del modello concettuale

7. L’utente preme il pulsante ‘Salva’

8. Il flusso termina all’ultimo passo del flusso base

3.6.2.4 Flusso alternativo F2 - creazione di una alternativa per una

domanda

1. L’utente, dopo il passo 4 del flusso alternativo F1, seleziona una delle domande

precedentemente create

2. Il sistema presenta una maschera di dettaglio del questionario selezionato

(figura 3.28) e la lista delle alternative preesistenti

3. L’utente preme il pulsante ‘Aggiungi alternativa’

67

Page 86: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.27: Gestione dei questionari, creazione di una nuova alternativa (flussoalternativo F2)

68

Page 87: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.28: Modifica di una domanda e lista alternative

Figura 3.29: Creazione di una domanda

69

Page 88: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

4. L’utente inserisce i dati necessari (figura 3.29), ovvero:

• testo dell’alternativa

• SIL minimo per cui l’alternativa diventa ‘High recommanded’ (solo se la

domanda corrispondente dipende dal SIL)

• alternativa padre (solo nel caso di alternativa di secondo livello)

5. Il sistema presenta il dettaglio della domanda.

3.6.2.5 Flusso alternativo F3 - creazione di una regola di esclusione

Figura 3.30: Gestione dei questionari, creazione di una nuova regola di esclusione(flusso alternativo F3)

70

Page 89: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

1. L’utente, dopo il passo 2 del flusso alternativo F2, seleziona una delle alterna-

tive precedentemente create

2. Il sistema presenta una maschera di dettaglio dell’alternativa selezionata (figu-

ra 3.31)

Figura 3.31: Modifica di una alternativa

3. L’utente preme il pulsante ‘Regole di esclusione’

4. Il sistema presenta la lista delle regole di esclusione preesistenti (figura 3.32)

Figura 3.32: Lista delle regole di esclusione per una domanda

71

Page 90: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

5. L’utente clicca il pulsante ‘Aggiungi nuova regola’

6. L’utente inserisce i dati necessari (figura 3.33), ovvero:

Figura 3.33: Creazione di una regola di esclusione

• domanda oggetto dell’esclusione

• alternativa che viene esclusa

7. L’utente preme il pulsante ‘Salva’

8. Il sistema presenta la lista delle regole di esclusione.

3.6.2.6 Flusso alternativo F4 - creazione di una regola di molteplicita

1. L’utente, dopo il passo 2 del flusso alternativo F3, preme il pulsante ‘Regole

di molteplicita’

2. Il sistema presenta la lista delle regole di molteplicita preesistenti

3. L’utente clicca il pulsante ‘Aggiungi nuova regola’

4. L’utente inserisce i dati necessari (figura 3.35), ovvero:

• domanda target

• tipo di molteplicita

• numero minimo e massimo di risposte (se viene selezionato il tipo rispsota

multipla’)

5. L’utente preme il pulsante ‘Salva’

6. Il sistema presenta la lista delle regole di molteplicita.

72

Page 91: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.34: Gestione dei questionari, creazione di una nuova regola di molteplicita(flusso alternativo F4)

Figura 3.35: Creazione di una regola di molteplicita

73

Page 92: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

3.6.3 Gestione degli utenti

L’attore che attiva il caso d’uso e l’amministratore.

3.6.3.1 Relazioni con altri casi d’uso

• Include ‘gestione delle organizzazioni’

3.6.3.2 Flusso principale

Figura 3.36: Gestione degli utenti, flusso principale

1. L’utente accede al sistema per creare una utenza.

2. Il sistema presenta la lista degli utenti precedentemente creati (figura 3.37)

3. L’utente preme il pulsante ‘Aggiungi nuova utenza’

74

Page 93: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.37: Lista delle utenze

Figura 3.38: Inserimento di una nuova utenza

75

Page 94: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

4. L’utente inserisce i dati necessari (figura 3.38), ovvero:

• nome dell’utente

• cognome

• password e relativo controllo

• organizzazione di cui fa parte l’utente

5. L’utente preme il pulsante ‘Salva’

6. Il sistema presenta la lista delle utenze

3.6.4 Gestione delle organizzazioni

L’attore che attiva il caso d’uso e l’amministratore.

3.6.4.1 Flusso principale

Figura 3.39: Gestione delle organizzazioni, flusso principale

76

Page 95: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

1. L’utente accede al sistema per creare una organizzazione.

2. Il sistema presenta la lista delle organizzazioni precedentemente create (figura

3.50)

Figura 3.40: Lista delle organizzazioni

3. L’utente preme il pulsante ‘Aggiungi nuova organizzazione’

4. L’utente inserisce i dati necessari (figura 3.41), ovvero:

Figura 3.41: Inserimento di una nuova organizzazione

• nome dell’organizzazione

• nazione

• tipo di organizzazione (software house oppure professional certifier)

5. L’utente preme il pulsante ‘Salva’

6. Il sistema presenta la lista delle organizzazioni.

77

Page 96: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

3.6.5 Gestione dei contratti

L’attore che attiva il caso d’uso e l’amministratore.

3.6.5.1 Relazioni con altri casi d’uso

• Include ‘gestione degli utenti’

• Include ‘gestione dei questionari’

3.6.5.2 Flusso principale

1. L’utente accede al sistema per creare un contratto.

2. Il sistema presenta la lista dei contratti precedentemente creati (figura 3.43)

3. L’utente preme il pulsante ‘Aggiungi contratto’

4. L’utente inserisce i dati necessari (figura 3.44), ovvero:

• nome del contratto

• questionario di riferimento

5. L’utente preme il pulsante ‘Salva’

6. Il sistema presenta la lista dei contratti

3.6.5.3 Flusso alternativo F1 - creazione di un ruolo

1. L’utente, dopo il passo 2 del flusso base, seleziona uno contratti preesistenti

dalla lista

2. Il sistema presenta una maschera di dettaglio del contratto selezionato (figura

3.46)

3. L’utente clicca il pulsante ‘Lista utenti’

4. Il sistema presenta la lista degli utenti ed il relativo ruolo (figura 3.47)

5. L’utente preme il pulsante ‘Aggiungi nomina’

6. L’utente inserisce i dati necessari (figura 3.48), ovvero:

• nome dell’utente (dalla tendina di quelli esistenti)

78

Page 97: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.42: Gestione dei contratti, flusso principale

79

Page 98: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.43: Lista dei contratti contratto

Figura 3.44: Inserimento di un nuovo contratto

80

Page 99: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.45: Gestione dei contratti, creazione di un ruolo (flusso alternativo F1)

81

Page 100: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.46: Dettaglio di un contratto

Figura 3.47: Lista dei ruoli utente per un contratto

Figura 3.48: Creazione di una ruolo utente

82

Page 101: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

• tipo di ruolo (dalla tendina di quelli predefiniti)

7. L’utente preme il pulsante ‘Salva’

8. Il flusso termina all’ultimo passo del flusso base

3.6.6 Gestione dei deliverables di default

L’attore che attiva il caso d’uso e l’amministratore.

3.6.6.1 Relazioni con altri casi d’uso

• Precede ‘gestione dei contratti’

3.6.6.2 Flusso principale

1. L’utente accede al sistema per creare un deliverable di default.

2. Il sistema presenta la lista dei deliverables di default precedentemente creati

(figura ??)

3. L’utente preme il pulsante ‘Aggiungi nuovo deliverable’

4. L’utente inserisce i dati necessari (figura 3.51), ovvero:

• nome del deliverable

• descrizione

• categoria (fra quelle predefinite)

• sottocategoria (fra quelle predefinite)

• tipo di deliverable

• on-site oppure off-site (se documento)

• for-information oppure for-validation (se documento)

5. L’utente preme il pulsante ‘Salva’

6. Il sistema presenta la lista dei deliverables di default.

3.6.7 Gestione dei deliverables del contratto

Gli attori che attivano il caso d’uso sono il supplier ed il certifier.

83

Page 102: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.49: Gestione dei deliverables di default, flusso principlae

84

Page 103: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.50: Lista dei deliverables di default

Figura 3.51: Inserimento di una nuova organizzazione

85

Page 104: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

3.6.7.1 Flusso principale

Figura 3.52: Gestione dei deliverables del contratto, flusso principlae

1. L’utente accede al sistema per creare un deliverable del contratto.

2. Il sistema presenta la lista dei deliverables di default precedentemente creati

(figura 3.53)

3. L’utente preme il pulsante ‘Aggiungi nuovo deliverable’

4. L’utente inserisce i dati necessari (figura 3.54), ovvero:

86

Page 105: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.53: Lista dei deliverables per il contratto

Figura 3.54: Inserimento di un nuovo deliverable per il contratto

87

Page 106: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

• nome del deliverable

• descrizione

• categoria (fra quelle predefinite)

• sottocategoria (fra quelle predefinite)

• tipo di deliverable

• on-site oppure off-site (se documento)

• for-information oppure for-validation (se documento)

5. L’utente preme il pulsante ‘Salva’

6. Il sistema presenta la lista dei deliverables per il contratto.

3.6.7.2 Flusso alternativo F1 - controllo dei deliverables vuoti e delle

evidenze non mappate

Figura 3.55: Gestione dei deliverables del contratto, controllo della matrice dimappatura (flusso alternativo F1)

1. L’utente, dopo il passo 2 del flusso base, preme il pulsante ‘Mappatura’

88

Page 107: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

2. Il sistema presenta una tabella (figura 3.56) delle evidenze, sulle righe, e dei

deliverables, sulle colonne, evidenziando: le evidenze non mappate in nessun

deliverable e i deliverables senza nessuna evidenza

Figura 3.56: Matrice evidenze-deliverables

3.6.8 Proposta degli elementi di prova

L’attore che attiva il caso d’uso e il supplier.

3.6.8.1 Relazioni con altri casi d’uso

• Precede ‘approvazione degli elementi di prova’

• Include ‘gestione dei deliverables di contratto’

3.6.8.2 Flusso principale

1. L’utente accede al sistema per proporre gli elementi di prova.

2. Il sistema presenta una maschera riassuntiva (figura 3.58) contenente le statis-

tiche di riempimento del questionario e all’approvazione delle domande, sia a

livello globale, sia a livello di package

3. L’utente sceglie dalla tendina dei packages quello contente le domande a che

intende rispondere (in alto a destra nella figura 3.58)

4. Il sistema mostra una maschera contenente la lista delle domande (figura 3.59),

ordinate per priorita dinamica1

1La priorita di una domanda dipende dal numero di regole che coinvolgono le sue alternative

89

Page 108: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.57: Proposta degli elementi di prova, flusso principiale

90

Page 109: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.58: Statistiche relative all’approvazione delle domande (supplier)

91

Page 110: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.59: Lista delle domande per un package del modello concettuale

92

Page 111: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

5. L’utente preme il pulsante ‘Rispondi’ vicino alla domanda a cui vuole rispon-

dere o di cui vuole modificare una precedente risposta

6. Il sistema mostra una maschera (figura 3.60) contenente la lista delle alterna-

tive, corredate dallo status di approvazione, se presente, e un resoconto storico

delle operazioni di modifica e di approvazione

Figura 3.60: Proposta delle evidenze

7. L’utente specifica le alternative di suo interesse, in accordo con le regole di

esclusione fra le alternative della domanda e delle altre domande. Inoltre

l’utente puo inserire delle informazioni aggiuntive per ciascuna alternativa

93

Page 112: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

8. L’utente preme il pulsante ‘Salva’

9. Il sistema richiede di commentare le modifiche apportate (figura 3.61)

Figura 3.61: Inserimento di commenti alle modifiche del set di evidenze proposte

10. L’utente inserisce un commento (non obbligatorio) e preme il pulsante ‘Salva’

11. Il sistema presenta la lista delle domande.

3.6.8.3 Flusso alternativo F1 - proposta del contenuto dei deliverables

1. L’utente, dopo il passo 4 del flusso base, preme il pulsante ‘Proponi’ vicino

alla domanda le cui evidenze vuole mappare dei deliverables del contratto

2. Il sistema mostra una maschera (figura 3.63) contenente la lista delle alterna-

tive, corredate dallo status di approvazione, se presente, e un resoconto storico

delle operazioni di modifica e di approvazione

3. L’utente specifica, per ciascuna alternativa/evidenza di suo interesse, i deliv-

erables che la includono

4. L’utente preme il pulsante ‘Salva’

5. Il flusso base riprende dal punto 8

94

Page 113: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.62: Proposta degli elementi di prova, proposta della mappatura neideliverables (flusso alternativo F1)

95

Page 114: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.63: Proposta del contenuto dei deliverables

96

Page 115: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

3.6.8.4 Flusso alternativo F2 - proposta delle relazioni fra le evidenze

1. L’utente, dopo il passo 4 del flusso base, preme il pulsante ‘Proponi’ di una

domanda relativa alle relazioni tra le evidenze per il package che sta lavorando

2. Il sistema mostra una maschera (figura 3.64) contenente la lista delle evidenze

disponbili per entrambi i concetti che fanno parte della relazione oggetto della

domanda

Figura 3.64: Proposta del contenuto dei deliverables

3. L’utente specifica, in forma libera, le coppie

4. L’utente preme il pulsante ‘Salva’

5. Il flusso base riprende dal punto 8

3.6.9 Approvazione degli elementi di prova

L’attore che attiva il caso d’uso e il certifier.

3.6.9.1 Flusso principale

1. L’utente accede al sistema per proporre gli elementi di prova.

2. Il sistema presenta una maschera riassuntiva (figura 3.67) contenente le statis-

tiche di riempimento del questionario e all’approvazione delle domande, sia a

livello globale, sia a livello di package

97

Page 116: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.65: Approvazione delle evidenze, prima parte del flusso principale

98

Page 117: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.66: Approvazione delle evidenze, seconda parte del flusso principale eapprovazione della domanda (flusso altenativo F1)

99

Page 118: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.67: Statistiche relative all’approvazione delle domande (certifier)

100

Page 119: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

3. L’utente sceglie dalla tendina dei package quello contente le domande che

intende approvare (in alto a destra nella figura 3.67)

4. Il sistema mostra una maschera contenente la lista delle domande (figura 3.78),

ordinate per priorita dinamica2

Figura 3.68: Lista delle domande per un package del modello concettuale

5. L’utente preme il pulsante ‘Proponi’, sotto la colonna ‘Accordo sulle eviden-

ze’, vicino alla domanda cui vuole dare approvazione o vuole modificare un

precedente giudizio

6. Il sistema mostra una maschera (figura 3.69) contenente la lista delle alter-

native, corredate dalle tendine con cui cambiare lo status di approvazione, se

2La priorita di una domanda dipende dal numero di regole che coinvolgono le sue alternative

101

Page 120: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

sono state precedentemente proposte, e un resoconto storico delle operazioni

di modifica e di approvazione

Figura 3.69: Approvazione delle evidenze

7. L’utente specifica lo status di approvazione per ciascuna evidenza di suo inter-

esse e pulsante ‘Salva’

8. Il sistema richiede di commentare le modifiche apportate (figura 3.70)

9. L’utente inserisce un commento (non obbligatorio) e preme il pulsante ‘Salva’

10. Il sistema presenta la lista delle domande.

3.6.9.2 Flusso alternativo F1 - approvazione della domanda

1. Il sistema, dopo il penultimo passo del flusso base, nel caso in cui tutte

le evidenze della domanda siano state approvate, mostra la maschera per

l’approvazione della domanda (figura 3.71)

102

Page 121: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.70: Inserimento di commenti alle modifiche dell’approvazione delle evidenze

Figura 3.71: Approvazione della domanda

103

Page 122: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

2. L’utente preme uno dei pulsanti ‘Approva’, ‘Approva parzialmente’ e ‘Disap-

prova’

3. Il flusso base riprende all’ultimo passo.

3.6.9.3 Flusso alternativo F2 - approvazione del contenuto dei deliver-

ables

Figura 3.72: Approvazione delle evidenze, approvazione del contenuto dei deliverable(flusso alternativo F2)

1. L’utente, dopo il passo 4 del flusso base, preme il pulsante ‘Proponi’, sotto la

colonna ‘Accordo sui deliverables’, vicino alla domanda cui vuole approvare la

mappatura delle evidenze nei deliverables del contratto

2. Il sistema mostra una maschera (figura 3.73) contenente la lista delle alter-

native, corredate dallo status di approvazione, e un resoconto storico delle

operazioni di modifica e di approvazione

3. L’utente approva ciascuna alternativa/evidenza di suo interesse, rispetto a tutti

deliverables in cui e stata proposta precedentemente la presenza dell’evidenza

104

Page 123: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.73: Approvazione del contenuto dei deliverables

4. L’utente preme il pulsante ‘Salva’

5. Il flusso base riprende dal punto 8

3.6.9.4 Flusso alternativo F3 - approvazione dell’istanziazione delle re-

lazioni

1. L’utente, dopo il passo 4 del flusso base, preme il pulsante ‘Proponi’, sotto la

colonna ‘Accordo sulle evidenze’, vicino ad una domanda relativa alle relazioni

tra concetti

2. Il sistema mostra una maschera (figura 3.74) contenente la lista delle evidenze

disponibili per entrambi i concetti relazionati e la risposta data dal produttore

3. L’utente approva o disapprova la risposta e preme il pulsante ‘Salva’

4. Il flusso base riprende dal punto 8

3.6.10 Gestione dei documenti del contratto

Gli attori che attivano il caso d’uso sono il supplier ed il certifier.

105

Page 124: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.74: Approvazione del contenuto dei deliverables

3.6.10.1 Flusso principale

1. L’utente accede al sistema per proporre un nuovo documento.

2. Il sistema presenta una maschera riassuntiva (figura 3.76) contenente la lista

dei documenti del contratto

3. Opzionalmente:

(a) L’utente preme il pulsante ‘Anteprima documento’

(b) Il sistema mostra la maschera per la personalizzazione del documento

(figura 3.77)

(c) L’utente specifica le opzioni desiderate relative all’informazione da includ-

ere, ovvero:

• diagrammi a torta delle statistiche

• evidenze

• deliverables

• matrice fra evidenze e deliverables

• storico delle evidenze

• storico dei deliverables

• domande di contesto

(d) Il sistema produce una anteprima del documento del contratto utilizzando

i dati disponibili, secondo le scelte dell’utente

106

Page 125: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.75: Gestione dei documenti del contratto, flusso principale

107

Page 126: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.76: Lista dei documenti del contratto

Figura 3.77: Maschera di personalizzazione dell’anteprima di un nuovo documento

108

Page 127: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

4. L’utente preme il pulsante ‘Aggiungi documento’

5. Il sistema mostra una maschera per la personalizzazione del documento (figura

??)

Figura 3.78: Maschera di personalizzazione del nuovo documento

6. L’utente inserisce un commento opzionale, inoltre specifica le opzioni desider-

ate relative all’informazione da includere, ovvero:

• diagrammi a torta delle statistiche

• evidenze

• deliverables

• matrice fra evidenze e deliverables

• storico delle evidenze

• storico dei deliverables

• domande di contesto

109

Page 128: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

7. L’utente preme il pulsante ‘Aggiungi’

8. Il sistema crea il documento e presenta la lista dei documenti.

3.6.10.2 Flusso alternativo F1 - approvazione del documento o della sua

cancellazione

Figura 3.79: Gestione dei documenti del contratto, approvazione di un documento(flusso alternativo F1)

1. L’utente, dopo il passo 2 del flusso base, preme il pulsante ‘Azioni’ vicino al

documenti che intende approvare o cancellare

2. Il sistema presenta una maschera di dettaglio (figura 3.80) contenente i dettagli

del documento e lo storico delle operazioni di modifica e di approvazione

3. L’utente preme uno dei pulsanti disponibili, in accordo con le proprie scelte

4. Il sistema cambia lo stato del documento, aggiunge una voce nello storico ed

aggiorna il dettaglio del documento

110

Page 129: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.80: Dettaglio del documento del contratto

3.7 Pattern, tecnologie e tecniche utilizzate

3.7.1 Pattern Model-View-Presenter

Un ‘pattern’ e la descrizione precisa di un problema che possiamo rilevare durante

lo sviluppo o la progettazione di un prodotto software. In un pattern, la descrizione

di un problema e delle condizioni che devono essere soddisfatte, e spesso piu impor-

tante della soluzione. In molti casi, infatti, una volta individuato il problema, la

soluzione e quasi immediata.

Model-View-Presenter e un pattern, di tipo architetturale, derivato del modello

software Model-View-Controller, usato per lo piu per la costruzione di interfacce

utente. Il Presenter assume la funzione di ‘mediatore’ (figura 3.81), sostituendo il

controllore delle applicazioni MVC. Inoltre, la vista e responsabile per la gestione

degli eventi dell’interfaccia utente (come mouseDown, keyDown, etc), che in MVC

e compito del controllore.

Abbiamo scelto di utilizzare questo pattern a causa della natura prototipale

del tool. Questo ci ha permesso di partizionare il problema nelle tre componenti e

migliorare sia manutenibilita che l’effort necessario alla gestione dei cambiamenti nei

requisiti. Per di piu adesso disponiamo di codice molto pulito ed estremamente riuti-

lizzabile per lo sviluppo di enhancement, oppure per la creazione di altre interfacce,

sia web che standalone di tipo fat-client o thin-client orientate ai web-services.

111

Page 130: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.81: Interazioni fra i componenti del pattern Model-View-Presenter

3.7.2 Framework per l’interfaccia web

Per lo sviluppo dell’interfaccia web del tool abbiamo utilizzato il framework open

source Vaadin, appositamente ideato per sviluppare Rich Internet Application: si

definiscono cosı le applicazioni web che forniscono un’esperienza all’utente del tutto

simile a quella che avrebbe con le applicazioni desktop.

In contrasto con le librerie Javascript e le soluzioni basate su plugin del browser,

Vaadin fa uso di una architettura (figura 3.82), improntata su Model-View-Presenter,

completamente server-side, cio significa che la maggior parte della logica applicativa

viene eseguito sul server. La tecnologia Ajax viene utilizzata lato client (browser)

per garantire agli utenti un’esperienza ricca e interattiva. Sul lato client Vaadin e

costruito sopra il Google Web Toolkit.

Ajax permette una comunicazione leggera, fra il browser ed il server web, evitan-

do cosı il download dell’intera pagina ad ogni richiesta, ovvero ogni click di un link

o di un bottone. Cio rende possibile la strutturazione dell’applicazione in un’unica

pagina web, a cui aggiungere e togliere componenti dinamicamente, tramite la co-

municazione Ajax. In tal senso, il client invia al server informazioni sugli elementi

con cui l’utente ha interagito, il server esegue la logica di business, e manda indietro

una sequenza di istruzioni, in formato JSON, che indica al browser come modificare

l’interfaccia3.

3per la descrizione approfondita del Client-Side Engine fare riferimento ahttp://vaadin.com/book/-/page/architecture.client-side.html

112

Page 131: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.82: Architettura del framework Vaadin

3.7.3 Object-relational mapping

L’ Object-Relational Mapping (ORM) e una tecnica di programmazione che

favorisce l’integrazione di sistemi software aderenti al paradigma della program-

mazione orientata agli oggetti con sistemi RDBMS. Un prodotto ORM fornisce,

mediante un’interfaccia orientata agli oggetti, tutti i servizi inerenti alla persistenza

dei dati, astraendo nel contempo le caratteristiche implementative dello specifico

RDBMS utilizzato. I principali vantaggi nell’uso di un tale sistema sono i seguenti:

• il superamento dell’incompatibilita di fondo tra il progetto orientato agli ogget-

ti ed il modello relazionale sul quale e basato il database management system;

• un’elevata portabilita rispetto alla tecnologia DBMS utilizzata: cambiando

DBMS non devono essere riscritte le routine che implementano lo strato di

persistenza, generalmente basta cambiare poche righe nella configurazione del

prodotto per l’ORM utilizzato;

• drastica riduzione della quantita di codice da produrre; l’ORM maschera dietro

semplici comandi le complesse attivita di creazione, selezione, aggiornamento

ed eliminazione dei dati (dette CRUD - Create, Read, Update, Delete). Tali

attivita occupano di solito una buona percentuale del tempo di stesura, testing

e manutenzione complessivo. Inoltre, sono per loro natura molto ripetitive

113

Page 132: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

e, dunque, favoriscono la possibilita che vengano commessi errori durante la

stesura del codice che le implementa;

• suggerisce la realizzazione dell’architettura di un sistema software mediante

approccio stratificato, isolando in un solo livello la logica di persistenza dei

dati, a vantaggio della modularita complessiva del sistema.

L’uso di un ORM4 favorisce il raggiungimento di piu alti standard qualitativi soft-

ware, migliorando in particolare le caratteristiche di correttezza, manutenibilita,

evolvibilita e portabilita.

Figura 3.83: Schema di Toplink, predecessore di EclipseLink

Il prodotto ORM che abbiamo scelto e EclipseLink5 v2.0, derivato da TopLink di

Oracle/Sun (la cui struttura e descritta in figura 3.83), che implementa le specifiche

Java Persistence API e si integra con Eclipse IDE. Esso offre molte funzionalita che

andrebbero realizzate manualmente dal programmatore:

• caricamento automatico del grafo degli oggetti, secondo i legami di associazione

fra tabelle: permette la produzione del codice delle classi che mappano le

tabelle;

4http://en.wikipedia.org/wiki/Object-relational mapping5http://en.wikipedia.org/wiki/EclipseLink

114

Page 133: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

• meccanismi di lazy-initialization: consento di eseguire le query ed istanziare

gli oggetti di una relazione soltanto quando sono effettivamente necessari;

• gestione della concorrenza nell’accesso ai dati: i conflitti durante la modifica di

un dato, da parte di piu utenti in contemporanea, possono essere automatica-

mente rilevati; l’implementazione prevede diverse tecniche di locking ottmistico

che velocizzano l’accesso in lettura contemporaneo ad uno in scrittura;

• meccanismi di caching dei dati;

• gestione della comunicazione mediante uso del design pattern ‘Unit of Work’,

che ritarda tutte le azioni di aggiornamento dei dati al momento della chiusura

della conversazione o di esplicite invocazioni programmatiche; inoltre la comu-

nicazione avviene mediante composizione di query multiple in un unico state-

ment sql, limitando cosı al minimo il numero di round-trip-time richiesti e,

conseguentemente, i tempi di risposta dell’applicazione

3.7.4 Java Architecture for XML Binding

Java Architecture for XML Binding (JAXB) permette agli sviluppatori di map-

pare le classi Java in rappresentazioni XML. JAXB fornisce due caratteristiche

principali: la capacita di gestire gli oggetti Java in XML, definito ‘marshalling’,

e l’inverso, vale a dire ‘unmarshalling’ da XML in oggetti Java. In altre parole,

JAXB permette di archiviare e recuperare dati in formato XML, senza la necessita

di attuare una serie di routine specifiche per la lettura e la scrittura di file XML.

Figura 3.84: Schema generale di funzionamento di JAXB

115

Page 134: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

JAXB e particolarmente utile quando la specifica e complessa e mutevole. In tal

caso, modificare regolarmente le definizioni dello schema XML per tenerle sincroniz-

zate con le definizioni Java puo richiedere molto tempo e produrre errori. JAXB

consente di automatizzare questo task tramite due tool:

• xjc puo essere usato per convertire uno Schema XML in classi annotate6

e per la creazione di Marshaller e Unmarshaller, attraverso un ’istanza di

JAXBContext;

• schemagen svolge in sostanza l’inverso di xjc, creando uno Schema XML da

un insieme di classi annotate.

3.8 Metriche

3.8.1 Relative al modello concettuale

Il modello concettuale che astrae lo standard IEC-61508 consta di:

• 10 packages (piu quello per le domande di contesto);

• 79 concetti e 7 classi di associazione;

• 111 attributi;

• 59 relazioni.

Per quanto riguarda, invece, il questionario approntato per le presentazioni, gli

screenshot nelle interfacce e l’esempio di documento (in appendice), esso consta di:

• 27 domande (su due concetti nel package ‘Process concepts’) di cui

– 4 di contesto;

– 19 relative ai concetti;

– 4 relative alle relazioni fra concetti;

• 379 alternative di cui 243 sono di secondo livello;

• 283 regole di esclusione;

• 8 deliverables.

6http://en.wikipedia.org/wiki/Java annotation

116

Page 135: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

3.8.2 Relative allo strumento

3.8.2.1 Stima dell’effort basato sui casi d’uso individuati

Item ValuePhase *Total Use Cases 10Unique Use Case Points (UUCP) 85Technical Complexity (TCF) 1,07Environmental Complexity(ECF) 0,75Use Case Points (UUCP * TCF * ECF) = UCP 68Estimated Hours per UUCP (HRS) 10Total Hours (HRS * UCP) 680Total Cost 27200

Tabella 3.1: Effort stimato per lo sviluppo del progetto

Metric Description Weight Value TCFTCF01 Distributed System 2 5 10TCF02 Response or throughput performance objectives 1 4 4TCF03 End user efficiency (online) 1 2 2TCF04 Complex internal processing 1 4 4TCF05 Code must be re-usable 1 2 2TCF06 Easy to install 0,5 5 2,5TCF07 Easy to use 0,5 3 1,5TCF08 Portable 2 3 6TCF09 Easy to change 1 3 3TCF10 Concurrent 1 2 2TCF11 Includ special security features 1 2 2TCF12 Provide direct access for third parties 1 5 5TCF13 Special user training faciities are required 1 3 3

Total: 47

Tabella 3.2: Technical Complexity Factors: metriche

Factor ValueUnadjusted TCF value (UTV) 47TCF Weighting (TWF) 0,01TCF Constant (TC) 0,6Technical Complexity Factor (TCF) = TC + (UTV * TWF) 1,07

Tabella 3.3: Technical Complexity Factors: fattori

117

Page 136: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Metric Description Weight Value TCFECF01 Familiar with Rational Unified Process 1,5 4 6ECF02 Application experience 0,5 3 1,5ECF03 Object-oriented experience 1 4 4ECF04 Lead analyst capability 0,5 4 2ECF05 Motivation 1 3 3ECF06 Stable requirements 2 4 8ECF07 Part-time workers -1 0 0ECF08 Difficult programming language -1 3 -3

Total: 21,5

Tabella 3.4: Environmental Complexity Factors: metriche

Factor ValueUnadjusted ECF value (UEV) 21,5ECF Weighting (EWF) -0,03ECF Constant (EC) 1,4Environmental Complexity Factor (ECF) = EC + (UEV * EWF) 0,75

Tabella 3.5: Environmental Complexity Factors: fattori

118

Page 137: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

3.8.2.2 Effort finale del progetto

Lo sviluppo del tool e iniziato il 15 Dicembre 2009 e si e concluso il 2 Novembre

2010, per una durata di undici mesi e una dimensione di ≈ 32, 5kLOC in linguaggio

JAVA. In questo arco temporale ci sono state undici release:

1. pre-alpha-1 (25 Dicembre): sviluppo del modulo ‘XML parser’, design del

database ed implementazioni delle classi entity, definizione della struttura

dell’interfaccia utente;

2. pre-alpha-2 (10 Gennaio): gestione dei modelli UML e creazione di questionari

e domande;

3. release 0.1.0 (11 Febbraio): amministrazione completa del questionario, creazione

degli accordi e dei ruoli utente, compilazione del questionario;

4. release 0.1.1 (20 Aprile): validazione delle evidenze;

5. release 0.1.2 (20 Maggio): prima versione del documento dell’accordo;

6. release 0.1.3 (2 Luglio): gestione dei documenti del contratto;

7. release 0.1.4 (23 Luglio): sviluppo del modulo ‘rules checking system’;

8. release 0.2.0 (15 Agosto): gestione dei deliverables del contratto;

9. release 0.2.1 (27 Settembre): gestione dei deliverables di default;

10. release 0.2.2 (29 Ottobre): gestione delle organizzazioni;

11. release 0.2.3 (2 Novembre): gestione delle domande sulle relazioni fra evidenze.

Si distinguono, inoltre, tre milestones:

1. 3 Marzo: presentazione dell’architettura della soluzione proposta;

2. 22 Aprile: presentazione di una demo funzionante;

3. 23 Luglio: presentazione della versione 0.1.4;

L’ultima versione del tool consta di:

• 10 package

• 162 classi

119

Page 138: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 3. DEFINIZIONE DEL PROCESSO E STRUMENTO ASUPPORTO

Figura 3.85: linee di codice totali e linee modificate per data

• 1458 metodi

• 741 attributi

• 32624 linee di codice di cui 19868 per la codifica dei metodi

120

Page 139: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

Capitolo 4Conclusioni e sviluppi futuri

‘Insegnare’ significa ‘mostrare

che e possibile’. ‘Apprendere’

vuole dire ‘rendere realizzabile

per se stessi’.

Paulo Coelho, Il cammino di

Santiago, 1987

In questo lavoro di Tesi Specialistica In Ingegneria Informatica, abbiamo af-

frontato alcuni tipici problemi della certificazione, secondo standard di qualita, di

sistemi ‘safety-critical’. Abbiamo studiato una metodologia innovativa, basando-

ci sulle ricerche del Simula Research Laboratory di Oslo, ed abbiamo progettato e

sviluppato uno strumento di supporto all’attivita di definizione di un accordo circa

le evidenze che il produttore deve fornire al certificatore. Come risvolto accademico,

la tesi mi ha permesso di applicare per intero le conoscenze acquisite dal corso di

‘Architetture, Analisi e Progettazione del Software’, ed in generale durante tutta la

carriera universitaria.

Questa tesi ha avuto come obiettivo primario la creazione di un mezzo con il

quale il certificatore puo trasferire la sua esperienza e competenza al produttore,

affinche egli acquisisca familiarita con uno standard completo e complesso come il

IEC-61508. Allo stesso modo, il certificatore riesce a comunicare, implicitamente, le

proprie aspettative, che, al contrario dello standard, non sono ne documentate ne

strutturate. Un altro obiettivo, non meno importante, e la possibilita, per il produt-

tore, di superare il divario generato dalla attuale mancanza di una caratterizzazione

sistematica degli elementi di prova. Egli e messo in condizioni di conoscere a priori

121

Page 140: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 4. CONCLUSIONI E SVILUPPI FUTURI

le evidenze da collezionare, in modo tale da poter svolgere questa attivita durante il

processo di sviluppo del prodotto, evitando costosi interventi successivi al rilascio.

Gli elementi innovativi della tesi si concentrano sulla definizione di un processo,

propedeutico a quello di certificazione di un prodotto, il cui obiettivo e la semplifi-

cazione e la razionalizzazione di quest’ultimo, con conseguente riduzione del costo

che deve sopportare un produttore di sistemi software ‘safety-critical’, sia termini di

sviluppo che di verifica.

Una cospicua parte dell’effort complessivo e stata impiegata per analizzare il

processo ‘AS IS’ della certificazione e comprendere le necessita dei vari utenti e

stakeholder. In particolare, per cogliere le problematiche e gli errori tipici delle

aziende che si avvicinano per la prima volta alla certificazione, oppure all’uso dello

standard di qualita IEC-61508. Alla conclusione di questa prima parte del lavoro di

tesi abbiamo prodotto il modello del processo ‘TO BE’.

Lo sviluppo del software di supporto e stato fruttuoso per valutare la fattibilita

della metodologia, e le nuove complessita a carico, soprattutto, del produttore,

interessato a massimizzare in margini di guadagno della sua attivita di business.

Da questo punto di vista, ci sembra una soluzione valida, ed adeguata, l’utiliz-

zazione del linguaggio naturale, tramite un questionario strutturato, per operare un

ragionamento su un modello rigido e rigoroso, nonche vasto e molto articolato.

Sebbene io abbia gia un’esperienza di cinque anni in un istituto di ricerca italiano

importante, come quello di Fisica Nucleare, questa esperienza, di ampio respiro, in

ambito europeo, mi ha permesso di mettere alla prova le mie capacita, e conoscenze,

in un progetto ampio e articolato, che ha messo in luce alcuni dei miei punti di

debolezza, motivandomi a progredire e migliorare ancora.

4.1 Sviluppi futuri

Per quanto riguarda gli sviluppi futuri, il tool puo essere migliorato andando

ad affinare le tecniche che realizzano il processo di definizione dell’accordo. In

particolare:

• il sistema di controllo delle regole potrebbe essere affinato affinche possa essere

snellita l’interfaccia di definizione del questionario;

• il meccanismo di routing fra le domande del questionario dovrebbe prevedere

la possibilita, per l’amministratore, di definire delle regole ad alta priorita, ad

122

Page 141: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

CAPITOLO 4. CONCLUSIONI E SVILUPPI FUTURI

esempio per fare in modo che le domande di contesto sia compilate prima di

tutte le altre;

• per le domande relative alle relazioni fra concetti del meta-modello, occor-

rerebbe sviluppare una interfaccia che suggerisca al produttore le relazioni

possibili, magari associate ad una probabilita; questa logica dovrebbe con-

siderare le relazioni gia selezionate dall’utente per computare con buona ap-

prossimazione le relazioni coerenti. Sempre in quest’ambito, poi, occorrerebbe

implementare un sistema di controllo delle molteplicita delle relazioni, estrap-

olandole dal modello concettuale;

• manca anche un sistema che possa costruire nuovi questionari sulla base di

quelli gia compilati e che, sempre su questi ultimi, e analizzando un insieme

minimale di risposte, ad esempio quelle alle domande di contesto, esegua una

prima compilazione del questionario.

123

Page 142: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

Bibliografia

[BCE+] Mark Bowell, George Cleland, Luke Emmet, George Cleland Adelard,

and Luke Emmet Adelard. Learning from incidents involving electri-

cal/electronic/programmable electronic safety-related systems - project

outline.

[Dea09] Harvey Dearden. Who’s afraid of iec 61508/61511 ?, 2009.

[DG05] B Dion and J Gartner. Efficient development of embedded automotive

software with iec 61508 objectives using scade drive. In In: VDI 12th

International Conference: Electronic Systems for Vehicles, VDI, pages

1427–1436, 2005.

[DMN] Msc Dissertation, Keith Moore, and Dr. Mark Nicholson. Safety critical

systems engineering.

[ES] Dr. Eric and W. Scharpf. Implementing iec61508 in the process

industries.

[ET10] Mehrdad Sabetzadeh Lionel Briand Rajwinder Panesar-Walawege

Emanuele Turella, Davide Falessi. Evidenceagreement: A collabora-

tive tool for planning the collection of safety evidence based on the iec

61508 standard., 2010.

[FD] Adrian Fletcher and Hse Department. Iec-61508: Safe plant design.

[Hau01] H J Hauge. A survey of software safety, 2001.

[HB+] Benediktsson Hunter, , O Benediktsson, R B Hunter, and A D

Mcgettrick. Processes for software in safety critical systems.

124

Page 143: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

BIBLIOGRAFIA

[IB] Benediktsson Science Institute and O. Benediktsson. Safety critical

software and development productivity.

[IBN97] U Isaksen, J P Bowen, and N Nissanke. System and software safety in

critical systems. Technical report, 1997.

[IEC98] IEC. Iec 61508: Functional safety of electrical/electronic/pro-

grammable electronic safety-related systems, 1998.

[Ita] Sandro Bologna Italian. Safety applications of programmable electronic

systems in the process industry: Impact of emerging standards.

[KS04] J C Knight and E A Strunk. Achieving critical system survivability

through software architectures architecting dependable, 2004.

[Lev] N Leveson. The role of software in spacecraft accidents. In A Per-

sonal Commitment to Software Quality. Pittsburgh, PA: The Software

Engineering Institute (SEI) 4. Jones, T.C. Programming Productivity.

[Lio96] J L Lions. Ariane 5 flight 501 failure report by the inquiry board.

european space agency (esa, 1996.

[LM97] P A Lindsay and J A McDermid. A systematic approach to soft-

ware safety integrity levels. In Proc. 16 th International Conference on

Computer Safety (SAFECOMP 97),York, pages 70–82. Springer Verlag,

1997.

[LS93] B Littlewood and L Strigini. Validation of ultrahigh dependability for

software-based systems. Com. ACM, pages 11–36, 1993.

[Mar] Martyn Thomas Martyn. Engineering judgement.

[Red00] Felix Redmill. Installing iec 61508 and supporting its users - nine

necessities, 2000.

[SG01] P Ninin L Scibile and S Grau. Functional safety: a total quality

approach. In 4 st WST Chamonix, 2001.

[Tim02] Clive Timms. Iec 61508 - is it pain or gain?, 2002.

[ver] Verification, validation, and certification issues of safety-critical

communication systems.

125

Page 144: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

BIBLIOGRAFIA

[WEWR09] Vidroha Debroy W. Eric Wong and Andrew Restrepo. The role of

software in recent catastrophic accidents, 2009.

[WMK02] R A Weaver, J A McDermid, and T P Kelly. Software safety argu-

ments: Towards a systematic categorisation of evidence. In Proc. 20 th

International System Safety Conference, Denver USA, System Safety

Society, 2002.

126

Page 145: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

Appendice ADocumento prodotto dal tool

On-line collaboration tool

supporting

agreement on evidence

127

Page 146: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

1.

2.

1.

2.

Introduction1. PurposeThis chapter provides general information about the Agreement

2. Agreement descriptionName: Demo (IEC61508)

Users

Supplier: Emanuele Turella

Certifier: Davide Falessi

Confidential

Page 1

128

Page 147: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

Overall statistics 1. Statistics

gio, 04 nov 2010 15:53:05 +0100

Page 2

129

Page 148: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

Agreement on evidence

Page 3

130

Page 149: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

Chapter 1: Package Definition_of_Context1. Statistics

gio, 04 nov 2010 15:53:05 +0100

Page 4

131

Page 150: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

1.1.

A.-

2.-

-

2.1.

A.-

2.-

2. Agreement on evidenceWhat is the minimum SIL to be achieved?

Proposed alternatives: SIL-4

Proposed (12-set-10 8:07 PM)

History of evidence:

[Supplier] The user has selected the following alternatives:

SIL-3

[Supplier] The user has selected the following alternatives:

SIL-4

In which country the product will be sold?Proposed alternatives:

Western Europe Proposed (22-ott-10 12:33 AM)

History of evidence:

[Supplier] The user has selected the following alternatives:

Western Europe

Agreement on evidence

Page 5

132

Page 151: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

Chapter 2: Package ProcessConcepts1. Statistics

gio, 04 nov 2010 15:53:05 +0100

Page 6

133

Page 152: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

1.1.

2.

3.

4.A.

-

-

-

-

5.-

-

-

2.1.

2.

3.

4.A.

2. Agreement on evidenceHow do you collect software safety requirements specification?

Final status: To specify

Evidence status: Agreed

Deliverables status: To specify

Proposed alternatives: 2a Semi-formal methods

Proposed (22-lug-10 4:27 PM)

Final agreement: Proposed

Agreement on evidence: Agreed (22-lug-10 6:18 PM)

Agreement on deliverables: Waiting for agreement

History of evidence:

[Supplier] The user has selected the following alternatives:

2a Semi-formal methods

[Certifier] 2a Semi-formal methods: Rejected (a comment)

[Certifier] 2a Semi-formal methods: Accepted

Which tecniques are you using to design the software architecture?Final status: To specify

Evidence status: Agreed

Deliverables status: To specify

Proposed alternatives: 1 Fault detection and diagnosis

Agreement on evidence

Page 7

134

Page 153: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

-

-

-

-

--

-

--

-

-

B.-

-

-

-

C.

-

-

-

-

5.-

-

-

Proposed (13-set-10 2:35 PM)

Final agreement: Proposed

Agreement on evidence: Agreed (22-lug-10 4:12 PM)

Agreement on deliverables: Waiting for agreement

Mapped in following deliverables:

Design specifications

Project Planning (Section 3)

History of deliverables:

[Supplier] The user has selected the following deliverables:

Design specifications

(this is a comment)

[Supplier] The user has selected the following deliverables:

Design specifications

()

[Supplier] The user has selected the following deliverables:

Feasibility Study

Project Planning

(This is a comment)

4 Graceful degradation Proposed (13-set-10 2:35 PM)

Final agreement: Proposed

Agreement on evidence: Agreed (22-lug-10 4:12 PM)

Agreement on deliverables: Waiting for agreement

7c Formal methods including for example, CCS, CSP, HOL, LOTOS, OBJ,temporal logic, VDM and Z

Proposed (13-set-10 2:35 PM)

Final agreement: Proposed

Agreement on evidence: Waiting for agreement

Agreement on deliverables: Waiting for agreement

History of evidence:

[Supplier] The user has selected the following alternatives:

1 Fault detection and diagnosis

4 Graceful degradation

7a Structured methods including for example, JSD, MASCOT, SADT and Yourdon.

[Certifier] 1 Fault detection and diagnosis: Accepted

4 Graceful degradation: Rejected

7a Structured methods including for example, JSD, MASCOT, SADT and Yourdon.:

Proposed

[Certifier] 1 Fault detection and diagnosis: Accepted

4 Graceful degradation: Accepted

7a Structured methods including for example, JSD, MASCOT, SADT and Yourdon.:

Accepted

gio, 04 nov 2010 15:53:05 +0100

Page 8

135

Page 154: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

-

-

-

-

3.1.

2.

3.

4.A.

-

-

-

-

5.-

-

-

-

[Supplier] The user has selected the following alternatives:

1 Fault detection and diagnosis

4 Graceful degradation

[Supplier] The user has selected the following alternatives:

1 Fault detection and diagnosis

4 Graceful degradation

7c Formal methods including for example, CCS, CSP, HOL, LOTOS, OBJ, temporal logic,

VDM and Z

CSP

HOL

LOTOS

[Supplier] The user has selected the following alternatives:

1 Fault detection and diagnosis

4 Graceful degradation

7b Semi-formal methods

CSP

HOL

LOTOS

[Supplier] The user has selected the following alternatives:

1 Fault detection and diagnosis

4 Graceful degradation

7c Formal methods including for example, CCS, CSP, HOL, LOTOS, OBJ, temporal logic,

VDM and Z

CSP

HOL

LOTOS

Wich tecniques do you use to achieve the software verification?Final status: To specify

Evidence status: Agreed

Deliverables status: To specify

Proposed alternatives: 3 Static analysis

Proposed (22-lug-10 4:53 PM)

Final agreement: Proposed

Agreement on evidence: Agreed (26-ott-10 6:20 PM)

Agreement on deliverables: Waiting for agreement

History of evidence:

[Supplier] The user has selected the following alternatives:

3 Static analysis (my first answer)

[Certifier] 3 Static analysis: Agreed

[Certifier] 3 Static analysis: Agreed

[Certifier] 3 Static analysis: Agreed

Agreement on evidence

Page 9

136

Page 155: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

4.1.

2.

3.

4.A.

-

-

-

-

--

-

-

--

5.-

5.1.

2.

3.

4.A.

-

-

-

-

--

-

--

B.-

-

-

-

--

-

Which tecniques do you use to assess functional safety?Final status: Waiting for agreement

Evidence status: Waiting for agreement

Deliverables status: Agreed

Proposed alternatives: 4 Failure analysis

Proposed (22-lug-10 12:54 PM)

Final agreement: Proposed

Agreement on evidence: Agreed (undefined)

Agreement on deliverables: Agreed

Mapped in following deliverables:

Feasibility Study

Change Control Plan

Resource Management Plan

History of deliverables:

[Certifier] Agreement set to: Agreed ()

History of evidence:

[Supplier] The user has selected the following alternatives:

4 Failure analysis

Which semi-formal methods are you using?Final status: Rejected

Evidence status: Rejected

Deliverables status: Agreed

Proposed alternatives: 2 Sequence diagrams

Proposed (22-lug-10 12:54 PM)

Final agreement: Proposed

Agreement on evidence: Agreed (22-lug-10 12:59 PM)

Agreement on deliverables: Agreed

Mapped in following deliverables:

Design specifications

Resource Management Plan

History of deliverables:

[Certifier] Agreement set to: Agreed ()

6 Decision/truth tables Proposed (22-lug-10 12:54 PM)

Final agreement: Proposed

Agreement on evidence: Agreed (22-lug-10 12:59 PM)

Agreement on deliverables: Agreed

Mapped in following deliverables:

Change Control Plan

Resource Management Plan

gio, 04 nov 2010 15:53:05 +0100

Page 10

137

Page 156: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

--

5.-

-

-

-

6.1.

2.

3.

4.A.

-

-

-

-

--

-

--

-

-

-

-

-

B.-

-

-

-

--

-

-

--

History of deliverables:

[Certifier] Agreement set to: Agreed ()

History of evidence:

[Supplier] The user has selected the following alternatives:

2 Sequence diagrams

6 Decision/truth tables

[Certifier] 2 Sequence diagrams: Accepted

6 Decision/truth tables: Accepted

[Supplier]

[Certifier]

Which tecniques are you using for static analysis?Final status: Partially agreed

Evidence status: Partially agreed

Deliverables status: Agreed

Proposed alternatives: 3 Control flow analysis

Proposed (22-lug-10 12:54 PM)

Final agreement: Proposed

Agreement on evidence: Agreed (17-ago-10 3:46 PM)

Agreement on deliverables: Agreed

Mapped in following deliverables:

Feasibility Study (222222222)

Design specifications (2222222222222222222222)

History of deliverables:

[Supplier] ()

[Supplier] The user has selected the following deliverables:

3 Control flow analysis (another comment)

[Certifier] Agreement set to: Proposed ()

[Certifier] Agreement set to: Agreed ()

[Certifier] Agreement set to: Rejected ()

[Certifier] Agreement set to: Agreed ()

4 Data flow analysis Proposed (22-lug-10 12:54 PM)

Final agreement: Proposed

Agreement on evidence: Agreed (17-ago-10 3:46 PM)

Agreement on deliverables: Agreed

Mapped in following deliverables:

Design specifications

Change Control Plan

Communications Plan

History of deliverables:

[Supplier] The user has selected the following deliverables: ()

Agreement on evidence

Page 11

138

Page 157: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

-

-

-

5.-

-

-

-

-

[Certifier] Agreement set to: Partially agreed ()

[Certifier] Agreement set to: Rejected ()

[Certifier] Agreement set to: Agreed ()

History of evidence:

[Supplier] The user has selected the following alternatives:

3 Control flow analysis

4 Data flow analysis

[Certifier] 3 Control flow analysis: Accepted

4 Data flow analysis: Accepted

[Certifier] 3 Control flow analysis: Accepted

4 Data flow analysis: Accepted

[Certifier] 3 Control flow analysis: Accepted

4 Data flow analysis: Accepted

[Certifier] 3 Control flow analysis: Agreed

4 Data flow analysis: Agreed

gio, 04 nov 2010 15:53:05 +0100

Page 12

139

Page 158: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

Chapter 3: Package

RequirementsConcepts1. Statistics

Agreement on evidence

Page 13

140

Page 159: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

1.1.

2.

3.

4.A.

-

-

-

-

5.-

6.

2.1.

2.

3.

4.A.

-

2. Agreement on evidenceWhich design and coding standard have you adopted?

Final status: To specify

Evidence status: Waiting for agreement

Deliverables status: To specify

Proposed alternatives: 1 Use of coding standard

Proposed (03-nov-10 5:36 PM)

Final agreement: Proposed

Agreement on evidence: Waiting for agreement

Agreement on deliverables: Waiting for agreement

History of evidence:

[Supplier] The user has selected the following alternatives:

1 Use of coding standard

Specification of relations between concepts

Which tecniques are you using for dynamic analysis and testing?Final status: Waiting for agreement

Evidence status: Waiting for agreement

Deliverables status: Partially agreed

Proposed alternatives: 1 Test case execution from boundary value analysis

Proposed (22-lug-10 12:54 PM)

gio, 04 nov 2010 15:53:05 +0100

Page 14

141

Page 160: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

-

-

-

--

-

-

5.-

6.-

3.1.

2.

3.

4.A.

-

-

-

-

--

5.-

6.

4.1.

2.

3.

4.A.

-

-

-

-

5.-

Final agreement: Proposed

Agreement on evidence: Agreed (undefined)

Agreement on deliverables: Waiting for agreement

History of deliverables:

[Certifier] Agreement set to: Proposed ()

[Certifier] Agreement set to: Agreed ()

[Certifier] Agreement set to: Partially agreed ()

History of evidence:

[Supplier] The user has selected the following alternatives:

1 Test case execution from boundary value analysis

Specification of relations between concepts

Relations between concepts OperatingMode and DesignatedState:

2 Fault tree analysis -> 1 Test case execution from boundary value analysis

Which tecniques are you using for functional and black-box testing?Final status: Waiting for agreement

Evidence status: Waiting for agreement

Deliverables status: Agreed

Proposed alternatives: 3 Boundary value analysis

Proposed (22-lug-10 12:55 PM)

Final agreement: Proposed

Agreement on evidence: Waiting for agreement

Agreement on deliverables: Agreed

History of deliverables:

[Certifier] Agreement set to: Agreed ()

History of evidence:

[Supplier] The user has selected the following alternatives:

3 Boundary value analysis

Specification of relations between concepts

Which tecniques are you using to analyze failures?Final status: To specify

Evidence status: Waiting for agreement

Deliverables status: To specify

Proposed alternatives: 2 Fault tree analysis

Proposed (22-lug-10 12:54 PM)

Final agreement: Proposed

Agreement on evidence: Waiting for agreement

Agreement on deliverables: Waiting for agreement

History of evidence:

[Supplier] The user has selected the following alternatives:

2 Fault tree analysis

Agreement on evidence

Page 15

142

Page 161: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

6.-

5.1.

2.

3.

4.A.

-

-

-

-

5.-

6.1.

2.

3.

4.A.

-

-

-

-

5.-

6.

Specification of relations between concepts

Relations between concepts OperatingMode and DesignatedState:

2 Fault tree analysis -> 1 Test case execution from boundary value analysis

Which modelling tecniques are you using?Final status: To specify

Evidence status: Waiting for agreement

Deliverables status: To specify

Proposed alternatives: 2 Finite state machines

Proposed (03-nov-10 5:36 PM)

Final agreement: Proposed

Agreement on evidence: Waiting for agreement

Agreement on deliverables: Waiting for agreement

History of evidence:

[Supplier] The user has selected the following alternatives:

2 Finite state machines

Which tecniques are you using to test performaces?Final status: To specify

Evidence status: Waiting for agreement

Deliverables status: To specify

Proposed alternatives: 1 Avalanche/stress testing

Proposed (03-nov-10 5:36 PM)

Final agreement: Proposed

Agreement on evidence: Waiting for agreement

Agreement on deliverables: Waiting for agreement

History of evidence:

[Supplier] The user has selected the following alternatives:

1 Avalanche/stress testing

Specification of relations between concepts

gio, 04 nov 2010 15:53:05 +0100

Page 16

143

Page 162: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

Mapping of evidences to deliverables1. Mapping matrix

D1 D2 D3 D4 D5 D6 D7 D8

Q1_E1Q2_E1 X X

Q2_E2Q2_E3Q3_E1Q4_E1 X X X

Q5_E1 X X

Q5_E2 X X

Q6_E1 X X

Q6_E2 X X X

Q7_E1Q8_E1Q9_E1Q10_E1Q11_E1Q12_E1Q13_E1Q14_E1

Q1_

E1

Q2_

E1

Q2_

E2

Q2_

E3

Q3_

E1

Q4_

E1

Q5_

E1

Q5_

E2

Q6_

E1

Q6_

E2

Q7_

E1

Q8_

E1

Q9_

E1

Q10

_E1

Q11

_E1

Q12

_E1

Q13

_E1

Q14

_E1

D1 X X

D2 X X X X

D3 X

D4 X X X

D5D6 X

D7 X X X

D8

Agreement on evidence

Page 17

144

Page 163: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

2. Evidences codes

How do you collect software safety requirements specification?Q1_E1 2a Semi-formal methods

Which tecniques are you using to design the software architecture?Q2_E1 1 Fault detection and diagnosisQ2_E2 4 Graceful degradationQ2_E3 7c Formal methods including for example, CCS, CSP, HOL, LOTOS, OBJ,

temporal logic, VDM and Z

Wich tecniques do you use to achieve the software verification?Q3_E1 3 Static analysis

Which tecniques do you use to assess functional safety?Q4_E1 4 Failure analysis

Which semi-formal methods are you using?Q5_E1 2 Sequence diagramsQ5_E2 6 Decision/truth tables

Which tecniques are you using for static analysis?Q6_E1 3 Control flow analysisQ6_E2 4 Data flow analysis

Which design and coding standard have you adopted?Q7_E1 1 Use of coding standard

Which tecniques are you using for dynamic analysis and testing?Q8_E1 1 Test case execution from boundary value analysis

Which tecniques are you using for functional and black-box testing?Q9_E1 3 Boundary value analysis

Which tecniques are you using to analyze failures?Q10_E1 2 Fault tree analysis

Which modelling tecniques are you using?Q11_E1 2 Finite state machines

gio, 04 nov 2010 15:53:05 +0100

Page 18

145

Page 164: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE A. DOCUMENTO PRODOTTO DAL TOOL

3. Deliverables codes

How do you collect software safety requirements specification?

Which tecniques are you using to test performaces?Q12_E1 1 Avalanche/stress testing

What is the minimum SIL to be achieved?Q13_E1 SIL-4

In which country the product will be sold?Q14_E1 Western Europe

Code Deliverable

D1 Feasibility Study

D2 Design specifications

D3 Project Planning

D4 Change Control Plan

D5 Risk Management Plan

D6 Communications Plan

D7 Resource Management Plan

D8 Responsibility assignment matrix

Agreement on evidence

Page 19

146

Page 165: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

Appendice BModello concettuale dettagliato

1. Package: IssueConcepts

(a) Concetto: Failure, eredita da Defect

i. Attributo: mistake, di tipo Mistake, molteplicita *..*

ii. Attributo: fault, di tipo Fault, molteplicita 1..*

iii. Attributo: testcase

iv. Attributo: error, di tipo Error, molteplicita *..*

(b) Concetto: Enhancement, eredita da Issue

(c) Concetto: Fault, eredita da Defect

i. Attributo: error, di tipo Error, molteplicita *..*

ii. Attributo: failure, di tipo Failure, molteplicita *..*

(d) Concetto: Mistake, eredita da Issue

i. Attributo: failure, di tipo Failure, molteplicita *..*

(e) Concetto: Error, eredita da Defect

i. Attributo: fault, di tipo Fault, molteplicita 1..*

ii. Attributo: failure, di tipo Failure, molteplicita *..*

(f) Concetto: Defect, eredita da Issue

i. Attributo: attribute1

(g) Concetto: Issue

i. Attributo: artifact, di tipo Report, molteplicita 1..*

ii. Attributo: requirement, di tipo Requirement, molteplicita *..*

iii. Attributo: artifact2, di tipo ControlledItem, molteplicita 1..*

147

Page 166: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE B. MODELLO CONCETTUALE DETTAGLIATO

iv. Attributo: activity, di tipo Activity, molteplicita 1..*

v. Attributo: change, di tipo Change, molteplicita *..*

2. Package: ConfigurationManagementConcepts

(a) Concetto: ControlledItem

i. Attributo: successors, di tipo ControlledItem, molteplicita *..*

ii. Attributo: issue2, di tipo Issue, molteplicita *..*

iii. Attributo: rationale, di tipo Rationale, molteplicita *..*

iv. Attributo: assumption, di tipo Assumption, molteplicita *..*

v. Attributo: version

(b) Concetto: Change

i. Attributo: resolution, di tipo Issue, molteplicita 1..*

ii. Attributo: rationale, di tipo Rationale, molteplicita *..*

iii. Attributo: , di tipo ControlledItem, molteplicita 1..*

3. Package: HazardConcepts

(a) Concetto: Hazard

Annotazione: ”’ ¡p align=left} ¡font size=2 face=Arial}¡font size=2 face=-

Arial}potential source of harm [Guide 51 ISO/IEC:1990]¡/font¿¡/font¿

¡/p¿ ¡p align=left} ¡font size=1 face=Arial}¡font size=1 face=Arial}NOTE:

The term includes danger to persons arising within a short time scale (for

example, fire and explosion) and also those that have a long-term effect on

a person’s health (for example, release of a toxic substance).¡/font¿¡/font¿

¡/p¿ ”’

i. Attributo: riskAssessment, di tipo Risk, molteplicita 1..*

ii. Attributo: requirement, di tipo Requirement, molteplicita 1..*

iii. Attributo: artifact, di tipo Artifact, molteplicita 1..*

(b) Concetto: Event

i. Attributo: initiatingMechanism, di tipo InitiatingMechanism, molteplic-

ita 1..*

(c) Concetto: Risk

i. Attributo: hazard, di tipo Hazard, molteplicita 1..*

ii. Attributo: consequence

iii. Attributo: target

148

Page 167: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE B. MODELLO CONCETTUALE DETTAGLIATO

iv. Attributo: artifact, di tipo Artifact, molteplicita 1..*

v. Attributo: toleranceLevel

vi. Attributo: likelihood

(d) Concetto: InitiatingMechanism

Annotazione: ”’ This is the trigger or initiator event(s) causing the haz-

ard to occur. The IM causes actualization or transformation of the hazard

from a dormant state to an active mishap state. ”’

i. Attributo: event, di tipo Event, molteplicita 1..*

(e) Concetto: HazardousElement

Annotazione: ”’ This is the basic hazardous resource creating the impetus

for the hazard, such as a hazardous energy source such as explosives being

used in the system. ”’

4. Package: JustificationConcepts

(a) Concetto: Rationale

Annotazione: ”’ ¡p¿ the fundamental reason or reasons serving to ac-

count for something.{br /¿ - In our case we need to account for why the

particulare requirement exists. ¡/p¿¡br /¿ ”’

i. Attributo: controlledItem, di tipo ControlledItem, molteplicita *..*

ii. Attributo: requirement, di tipo Requirement, molteplicita *..*

iii. Attributo: change, di tipo Change, molteplicita *..*

iv. Attributo: assumption, di tipo Assumption, molteplicita *..*

(b) Concetto: Assumption

Annotazione: ”’ ¡p align=left} ¡font size=3 face=Times New Roman}¡font

size=3 face=Times New Roman}An¡/font¿¡/font¿ ¡b¿¡i¿¡font size=3 face=-

Times New Roman}¡font size=3 face=Times New Roman}assumption¡/font¿¡/font¿¡/i¿¡/b¿

¡font size=3 face=Times New Roman}¡font size=3 face=Times New Ro-

man}is a statement to be satisfied by the environment, and formulated

in terms of environment phenomena¡/font¿¡/font¿ ¡/p¿ ”’

i. Attributo: rationale, di tipo Rationale, molteplicita *..*

5. Package: SystemConcepts

(a) Concetto: Interface

i. Attributo: , di tipo Block, molteplicita 1..*

149

Page 168: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE B. MODELLO CONCETTUALE DETTAGLIATO

(b) Concetto: ProgrammableElectronicSystem, eredita da Block

Annotazione: ”’ ¡p align=left} ¡font size=2 face=Arial}¡font size=2 face=-

Arial}system for control, protection or monitoring based on one or more

programmable electronic devices, including all elements of the system

such as power supplies, sensors and other input devices, data highways

and other communication paths, and actuators and other output de-

vices¡/font¿¡/font¿ ¡/p¿ ”’

i. Attributo: hardwareBlock, di tipo HardwareBlock, molteplicita 1..*

ii. Attributo: pESSafetyRequirementsSpecification

iii. Attributo: softwareSystem, di tipo SoftwareBlock, molteplicita 1..*

iv. Attributo: userRole, di tipo UserRole, molteplicita *..*

(c) Concetto: NonProgrammableHardwareBlock, eredita da HardwareBlock

Annotazione: ”’ ¡p align=left} electro-mechanical devices (electrical);or

solid-state non-programmable electronic devices (electronic); ¡/p¿ ”’

(d) Concetto: UserRole

i. Attributo: programmableElectronicSystem, di tipo Programmable-

ElectronicSystem, molteplicita *..*

(e) Concetto: ProgrammableHardwareBlock, eredita da HardwareBlock

Annotazione: ”’ ¡p align=left} ¡font size=2 face=Arial}¡font size=2 face=-

Arial}any physical entity based on computer technology which may be

comprised of hardware, software, and of input and/or output units¡/font¿¡/font¿

¡/p¿ ”’

i. Attributo: nonprogrammableHardwareBlock, di tipo NonProgrammable-

HardwareBlock, molteplicita *..*

(f) Concetto: Block, eredita da ControlledItem

Annotazione: ”’ entity of hardware or software, or both, capable of ac-

complishing a specified purpose¡br /¿ NOTE: In IEV 191-01-01 the more

general term ’item’ is used in place of functional unit. An item may

sometimes include people. ”’

i. Attributo: requirement, di tipo Requirement, molteplicita *..*

ii. Attributo: artifact, di tipo Artifact, molteplicita *..*

iii. Attributo: type, di tipo BlockType, molteplicita 1..*

(g) Concetto: SoftwareBlock, eredita da Block

Annotazione: ”’ any entity of software that may be used for controlling

150

Page 169: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE B. MODELLO CONCETTUALE DETTAGLIATO

the system -this may be embedded or application software or even dif-

ferent levels of software such ad module, component, subsystem, system.

”’

i. Attributo: programmableElectronicSystem, di tipo Programmable-

ElectronicSystem, molteplicita 1..*

ii. Attributo: level, di tipo SoftwareLevel, molteplicita 1..*

(h) Concetto: HardwareBlock, eredita da Block

Annotazione: ”’ any entity of hardware -this may be mechanical, electri-

cal or electronic that is used in the composition of the system ”’

i. Attributo: programmableElectronicSystem, di tipo Programmable-

ElectronicSystem, molteplicita 1..*

6. Package: ArtifactConcepts

(a) Concetto: Specification, eredita da Artifact

Annotazione: ”’ ¡p align=left} ¡font size=2 face=Arial}¡font size=2 face=-

Arial}specifies a required function, performance or activity (for example

requirements specification);¡/font¿¡/font¿ ¡/p¿ ”’

(b) Concetto: Report, eredita da Artifact

Annotazione: ”’ ¡p align=left} ¡font size=2 face=Arial}¡font size=2 face=-

Arial}describes the results of activities such as investigations, assess-

ments, tests etc. (for example test report);¡/font¿¡/font¿ ¡/p¿ ”’

i. Attributo: issue, di tipo Issue, molteplicita *..*

(c) Concetto: Request, eredita da Artifact

Annotazione: ”’ ¡p align=left} ¡font size=2 face=Arial}¡font size=2 face=-

Arial}provides a description of requested actions that have to be approved

and further specified (for example maintenance request).¡/font¿¡/font¿

¡/p¿ ”’

(d) Concetto: Instruction, eredita da Artifact

Annotazione: ”’ ¡p align=left} ¡font size=2 face=Arial}¡font size=2 face=-

Arial}specifies in detail the instructions as to when and how to perform

certain jobs (for example operator instruction);¡/font¿¡/font¿ ¡/p¿ ”’

(e) Concetto: List, eredita da Artifact

Annotazione: ”’ ¡p¿ ¡font size=2 face=Arial}¡font size=2 face=Arial}provides

information in a list form (for example code list, signal list);¡/font¿¡/font¿

¡/p¿ ”’

151

Page 170: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE B. MODELLO CONCETTUALE DETTAGLIATO

(f) Concetto: Diagram, eredita da Artifact

Annotazione: ”’ ¡p align=left} ¡font size=2 face=Arial}¡font size=2 face=-

Arial}specifies the function by means of a diagram (symbols and lines)

representing signals between the symbols;¡/font¿¡/font¿ ¡/p¿ ”’

(g) Concetto: Artifact, eredita da ControlledItem

Annotazione: ”’ Artifact ”’

i. Attributo: softwareOperationandModificationProceduresDevelopment

ii. Attributo: block, di tipo Block, molteplicita 1..*

iii. Attributo: standard, di tipo Standard, molteplicita *..*

iv. Attributo: testcase

v. Attributo: output, di tipo Activity, molteplicita *..*

vi. Attributo: input, di tipo Activity, molteplicita *..*

vii. Attributo: test da diag, di tipo SoftwareLevel, molteplicita 1..*

viii. Attributo: risk, di tipo Risk, molteplicita 1..*

ix. Attributo: agent, di tipo Agent, molteplicita 1..*

x. Attributo: state, di tipo ArtifactStateType, molteplicita 1..*

xi. Attributo: requirement, di tipo Requirement, molteplicita *..*

xii. Attributo: hazard, di tipo Hazard, molteplicita 1..*

(h) Concetto: Plan, eredita da Artifact

Annotazione: ”’ ¡p align=left} ¡font size=2 face=Arial}¡font size=2 face=-

Arial}specifies the plan as to when, how and by whom specific activities

shall be performed (for example maintenance plan);¡/font¿¡/font¿ ¡/p¿ ”’

(i) Concetto: Log, eredita da Artifact

Annotazione: ”’ ¡p¿ ¡font size=2 face=Arial}¡font size=2 face=Arial}provides

information on events in a chronological log form;¡/font¿¡/font¿ ¡/p¿ ”’

(j) Concetto: ArtifactLink

i. Attributo: testtest, di tipo Artifact, molteplicita *..*

ii. Attributo: type, di tipo ArtifactLinkType, molteplicita 1..*

(k) Concetto: Description, eredita da Artifact

Annotazione: ”’ ¡p align=left} ¡font size=2 face=Arial}¡font size=2 face=-

Arial}specifies a planned or actual function, design, performance or ac-

tivity (for example function description);¡/font¿¡/font¿ ¡/p¿ ”’

7. Package: GuidanceConcepts

152

Page 171: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE B. MODELLO CONCETTUALE DETTAGLIATO

(a) Concetto: SectorSpecificStandard, eredita da Standard

Annotazione: ”’ a standard that provides recommendations on a specific

subject to a specific domain ”’

(b) Concetto: GeneralStandard, eredita da Standard

Annotazione: ”’ ¡p¿ a standard that provides generic recommendations

on a specific subject to a number of related domains. ¡/p¿ ”’

(c) Concetto: RecommendedPractice, eredita da Source

Annotazione: ”’ sound practices and guidance for the achievement of a

particular objective. ”’

(d) Concetto: Standard, eredita da Source

Annotazione: ”’ ¡p¿ A technical standard is an established norm or re-

quirement. It is usually a formal document that establishes uniform engi-

neering or technical criteria, methods, processes and practices.¡br /¿ ¡/p¿

”’

i. Attributo: artifact, di tipo Artifact, molteplicita *..*

8. Package: ProcessConcepts

(a) Concetto: TechniqueRecommendation

i. Attributo: , di tipo SafetyIntegrityLevel, molteplicita 1..*

(b) Concetto: Organization, eredita da Agent

Annotazione: ”’ ¡p¿ is a ¡a class=new title=Social arrangement (page

does not exist) href=http://en.wikipedia.org/w/index.php?title=Social -

arrangement&action=edit&redlink=1}social arrangement¡/a¿ which pur-

sues collective goals, which controls its own performance, and which has

a boundary separating it from its environment ¡/p¿ ”’

(c) Concetto: Technique

i. Attributo: activity, di tipo Activity, molteplicita *..*

(d) Concetto: Individual, eredita da Agent

Annotazione: ”’ ¡p¿ refers to a person ¡/p¿ ”’

(e) Concetto: Competence

Annotazione: ”’ ¡p¿ is the ability to perform a specific task, action or

function successfully. ¡/p¿¡br /¿ ”’

i. Attributo: activity, di tipo Activity, molteplicita *..*

ii. Attributo: competence, di tipo Competence, molteplicita *..*

153

Page 172: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE B. MODELLO CONCETTUALE DETTAGLIATO

iii. Attributo: agent, di tipo Agent, molteplicita *..*

iv. Attributo: competence2, di tipo Competence, molteplicita *..*

(f) Concetto: Phase

Annotazione: ”’ a set of activities with determined inputs and ouput that

are carried out at a specific time during the life of a system ”’

i. Attributo: precedes, di tipo Phase, molteplicita 1..*

ii. Attributo: succeeds, di tipo Phase, molteplicita 1..*

iii. Attributo: activity, di tipo Activity, molteplicita 1..*

(g) Concetto: Agent, eredita da Source

Annotazione: ”’ An abstract concept that can represent an person or

organization that has the capability and responsibility for carrying out

and activity. ”’

i. Attributo: type, di tipo AgentType, molteplicita 1..*

ii. Attributo: activity, di tipo Activity, molteplicita 1..*

iii. Attributo: capability, di tipo Competence, molteplicita 1..*

iv. Attributo: artifact, di tipo Artifact, molteplicita *..*

(h) Concetto: Activity

Annotazione: ”’ an activity may be thought of as a unit of behaviour in

a process. ”’

i. Attributo: activity2, di tipo Activity, molteplicita 1..*

ii. Attributo: issue, di tipo Issue, molteplicita *..*

iii. Attributo: agent, di tipo Agent, molteplicita 1..*

iv. Attributo: capability, di tipo Competence, molteplicita 1..*

v. Attributo: requires, di tipo Artifact, molteplicita *..*

vi. Attributo: activity, di tipo Activity, molteplicita *..*

vii. Attributo: technique, di tipo Technique, molteplicita *..*

viii. Attributo: produces, di tipo Artifact, molteplicita *..*

ix. Attributo: lifecyclePhase, di tipo Phase, molteplicita 1..*

9. Package: RequirementsConcepts

(a) Concetto: Source

Annotazione: ”’ An abstract concept that can represent an person,

standard tat can be a source or requirements to a system. ”’

i. Attributo: requirement, di tipo Requirement, molteplicita *..*

154

Page 173: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE B. MODELLO CONCETTUALE DETTAGLIATO

(b) Concetto: DesignatedState

i. Attributo: operatingMode, di tipo OperatingMode, molteplicita 1..*

(c) Concetto: RequirementLink

i. Attributo: source, di tipo Requirement, molteplicita *..*

ii. Attributo: target, di tipo Requirement, molteplicita *..*

iii. Attributo: type, di tipo RequirementLinkType, molteplicita 1..*

(d) Concetto: ResidualRisk

i. Attributo: , di tipo Risk, molteplicita 1..*

(e) Concetto: Requirement

Annotazione: ”’ ¡div style=WHITE-SPACE: nowrap id=titlebar} A nec-

essary attribute in a system; a statement that identifies a capability,

characteristic, or quality factor of a system in order for it to have value

and utility to a user. ¡/div¿ ”’

i. Attributo: artifact, di tipo Artifact, molteplicita 1..*

ii. Attributo: block, di tipo Block, molteplicita 1..*

iii. Attributo: type, di tipo RequirementType, molteplicita 1..*

iv. Attributo: operatingContext, di tipo OperatingMode, molteplicita

1..*

v. Attributo: rationale, di tipo Rationale, molteplicita *..*

vi. Attributo: issue, di tipo Issue, molteplicita *..*

vii. Attributo: source, di tipo Source, molteplicita *..*

viii. Attributo: hazard, di tipo Hazard, molteplicita *..*

(f) Concetto: OperatingMode

Annotazione: ”’ This could refer to the different modes that a system

can be operating in, e.g. normal, maintenance, test, emergency ”’

i. Attributo: requirement, di tipo Requirement, molteplicita *..*

ii. Attributo: type, di tipo OperatingModeType, molteplicita 1..*

iii. Attributo: designatedState, di tipo DesignatedState, molteplicita

*..*

(g) Concetto: SafeState, eredita da DesignatedState

(h) Concetto: SafetyRequirement, eredita da Requirement

Annotazione: ”’ a prescriptive statement that ensures that the system

carries out its functions in an acceptabley safe manner ”’

155

Page 174: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE B. MODELLO CONCETTUALE DETTAGLIATO

i. Attributo: safetyIntegrityLevel, di tipo SafetyIntegrityLevel, molteplic-

ita 1..*

(i) Concetto: UnsafeState, eredita da DesignatedState

(j) Concetto: SafetyIntegrityLevel

Annotazione: ”’ ¡p align=left} ¡font size=2 face=Arial}¡font size=2 face=-

Arial}discrete level (one out of a possible four) for specifying the safety in-

tegrity requirements of the safety functions to be allocated to the E/E/PE

safety-related systems, where safety integrity level 4 has the highest level

of safety integrity and safety integrity level 1 has the lowest.¡/font¿¡/font¿

This could be an interval or the SIL level such as 1,2,3,or 4 ¡/p¿ ”’

i. Attributo: value

ii. Attributo: safetyRequirement, di tipo SafetyRequirement, molteplic-

ita *..*

iii. Attributo: failureRateUnit

10. Package: DomainSpecificConcepts

(a) Concetto: OperatingModeType

Annotazione: ”’ an enumeration that gives examples of operating modes.

”’

i. Letterale: StartUp

ii. Letterale: Manual

iii. Letterale: PreparationForUse

iv. Letterale: Resetting

v. Letterale: ShutDown

vi. Letterale: SemiAutomatic

vii. Letterale: Teaching

viii. Letterale: Automatic

ix. Letterale: Maintenance

x. Letterale: SteadyState

xi. Letterale: AbnormalCondition

(b) Concetto: SoftwareLevel

Annotazione: ”’ the different mayw in which a software system can be

decomposed. ”’

i. Letterale: System

156

Page 175: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE B. MODELLO CONCETTUALE DETTAGLIATO

ii. Letterale: Module

iii. Letterale: Component

iv. Letterale: Subsystem

(c) Concetto: BlockType

i. Letterale: Actual

ii. Letterale: Stub

(d) Concetto: RequirementLinkType

Annotazione: ”’ an enumeration that gives examples of the types of

traceability that can exist between requirements. ”’

i. Letterale: InteractsWith

ii. Letterale: Denies

iii. Letterale: Refines

iv. Letterale: Overrides

v. Letterale: IsAllocatedTo

vi. Letterale: Enables

vii. Letterale: IsDerivedFrom

(e) Concetto: ArtifactLinkType

i. Letterale: RefersTo

ii. Letterale: ResultsIn

iii. Letterale: IsDerivedFrom

(f) Concetto: AgentType

Annotazione: ”’ enumeration to describe the different roles that agents

can play. ”’

i. Letterale: Integrator

ii. Letterale: Operator

iii. Letterale: Owner

iv. Letterale: Supplier

v. Letterale: Certifier

(g) Concetto: RequirementType

i. Letterale: Functionality

ii. Letterale: Availability

iii. Letterale: Efficiency

iv. Letterale: Performance

157

Page 176: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE B. MODELLO CONCETTUALE DETTAGLIATO

v. Letterale: Usability

vi. Letterale: Integratability

vii. Letterale: Portability

viii. Letterale: Maintainability

(h) Concetto: IssueStateType

i. Letterale: Resolved

ii. Letterale: Created

iii. Letterale: Analysed

(i) Concetto: ArtifactStateType

i. Letterale: Reviewed

ii. Letterale: Revised

iii. Letterale: Approved

iv. Letterale: Created

158

Page 177: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

Appendice CQuestionario d’esempio

1. What is the minimum SIL to be achieved?

(a) SIL-1

(b) SIL-2

(c) SIL-3

(d) SIL-4

2. How do you collect software safety requirements specification?

(a) 1 Computer-aided specification tools

SIL minimo: 3

(b) 2a Semi-formal methods

SIL minimo: 3

(c) 2b Formal methods including for example, CCS, CSP, HOL, LOTOS,

OBJ, temporal logic, VDM and Z

SIL minimo: 4

Esclude:

i. 2a Semi-formal methods

Alternative di secondo livello:

i. CSP

ii. CCS

iii. LOTOS

iv. HOL

3. Which tecniques are you using to design the software architecture?

159

Page 178: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE C. QUESTIONARIO D’ESEMPIO

(a) 1 Fault detection and diagnosis

SIL minimo: 3

(b) 2 Error detecting and correcting codes

SIL minimo: 4

(c) 3a Failure assertion programming

SIL minimo: 4

(d) 3b Safety bag techniques

SIL minimo: Never

Esclude:

i. 3a Failure assertion programming

(e) 3c Diverse programming

SIL minimo: 4

Esclude:

i. 3a Failure assertion programming

ii. 3b Safety bag techniques

(f) 3d Recovery block

SIL minimo: Never

Esclude:

i. 3a Failure assertion programming

ii. 3b Safety bag techniques

iii. 3c Diverse programming

(g) 3e Backward recovery

SIL minimo: Never

Esclude:

i. 3a Failure assertion programming

ii. 3b Safety bag techniques

iii. 3c Diverse programming

iv. 3d Recovery block

(h) 3f Forward recovery

SIL minimo: Never

Esclude:

i. 3a Failure assertion programming

ii. 3b Safety bag techniques

160

Page 179: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE C. QUESTIONARIO D’ESEMPIO

iii. 3c Diverse programming

iv. 3d Recovery block

v. 3e Backward recovery

(i) 3g Re-try fault recovery mechanisms

SIL minimo: 4

Esclude:

i. 3a Failure assertion programming

ii. 3b Safety bag techniques

iii. 3c Diverse programming

iv. 3d Recovery block

v. 3e Backward recovery

vi. 3f Forward recovery

(j) 3h Memorising executed cases

SIL minimo: 4

Esclude:

i. 3a Failure assertion programming

ii. 3b Safety bag techniques

iii. 3c Diverse programming

iv. 3d Recovery block

v. 3e Backward recovery

vi. 3f Forward recovery

vii. 3g Re-try fault recovery mechanisms

(k) 4 Graceful degradation

SIL minimo: 3

(l) 5 Artificial intelligence - fault correction

SIL minimo: Never

(m) 6 Dynamic reconfiguration

SIL minimo: Never

(n) 7a Structured methods including for example, JSD, MASCOT, SADT

and Yourdon.

(o) 7b Semi-formal methods

SIL minimo: 3

Esclude:

161

Page 180: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE C. QUESTIONARIO D’ESEMPIO

i. 7a Structured methods including for example, JSD, MASCOT, SADT

and Yourdon.

(p) 7c Formal methods including for example, CCS, CSP, HOL, LOTOS,

OBJ, temporal logic, VDM and Z

SIL minimo: 1

Esclude:

i. 7a Structured methods including for example, JSD, MASCOT, SADT

and Yourdon.

ii. 7b Semi-formal methods

Alternative di secondo livello:

i. CCS

ii. CSP

iii. HOL

iv. LOTOS

v. OBJ

(q) 8 Computer-aided specification tools

SIL minimo: 3

4. Which support tools and programming language are you using to develope the

software?

(a) 1 Suitable programming language

(b) 2 Strongly typed programming language

(c) 3 Language subset

SIL minimo: 3

(d) 4a Certificated tools

SIL minimo: 2

(e) 4b Tools: increased confidence from use

SIL minimo: 1

Esclude:

i. 4a Certificated tools

(f) 5a Certificated translator

SIL minimo: 2

(g) 5b Translator: increased confidence from use

SIL minimo: 1

Esclude:

162

Page 181: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE C. QUESTIONARIO D’ESEMPIO

i. 5a Certificated translator

(h) 6 Library of trusted/verified software modules and components

SIL minimo: 2

5. Which tecniques are you using for detailed design?

(a) 1a Structured methods including for example, JSD, MASCOT, SADT

and Yourdon

(b) 1b Semi-formal methods

SIL minimo: 2

Esclude:

i. 1a Structured methods including for example, JSD, MASCOT, SADT

and Yourdon

(c) 1c Formal methods including for example, CCS, CSP, HOL, LOTOS,

OBJ, temporal logic, VDM and Z

SIL minimo: 4

Esclude:

i. 1a Structured methods including for example, JSD, MASCOT, SADT

and Yourdon

ii. 1b Semi-formal methods

(d) 2 Computer-aided design tools

SIL minimo: 3

(e) 3 Defensive programming

SIL minimo: 3

(f) 4 Modular approach

(g) 5 Design and coding standards

SIL minimo: 2

(h) 6 Structured programming

(i) 7 Use of trusted/verified software modules and components (if available)

6. How do you verify software modules and their integration?

(a) 1 Probabilistic testing

SIL minimo: 4

(b) 2 Dynamic analysis and testing

(c) 3 Data recording and analysis

163

Page 182: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE C. QUESTIONARIO D’ESEMPIO

(d) 4 Functional and black box testing

(e) 5 Performance testing

(f) 6 Interface testing

SIL minimo: 3

7. How do you verify the programmable electonics integration?

(a) 1 Functional and black box testing

(b) 2 Performance testing

8. How do you verify software safety?

(a) 1 Probabilistic testing

SIL minimo: 4

(b) 2 Simulation/modelling

SIL minimo: 3

(c) 3 Functional and black-box testing

9. Wich tecniques do you use to manage modifications?

(a) 1 Impact analysis

(b) 2 Reverify changed software module

(c) 3 Reverify affected software modules

SIL minimo: 2

(d) 4 Revalidate complete system

SIL minimo: 3

(e) 5 Software configuration management

(f) 6 Data recording and analysis

10. Wich tecniques do you use to achieve the software verification?

(a) 1 Formal proof

SIL minimo: 4

(b) 2 Probabilistic testing

SIL minimo: 4

(c) 3 Static analysis

(d) 4 Dynamic analysis and testing

164

Page 183: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE C. QUESTIONARIO D’ESEMPIO

(e) 5 Software complexity metrics

SIL minimo: Never

11. Which tecniques do you use to assess functional safety?

(a) 1 Checklists

SIL minimo: Never

(b) 2 Decision/truth tables

SIL minimo: Never

(c) 3 Software complexity metrics

SIL minimo: Never

(d) 4 Failure analysis

SIL minimo: 3

(e) 5 Common cause failure analysis of diverse software (if diverse software

is actually used)

SIL minimo: 3

(f) 6 Reliability block diagram

SIL minimo: Never

12. Which design and coding standard have you adopted?

(a) 1 Use of coding standard

(b) 2 No dynamic objects

SIL minimo: 2

(c) 3a No dynamic variables

SIL minimo: 3

(d) 3b Online checking of the installation of dynamic variables

SIL minimo: 3

Esclude:

i. 3a No dynamic variables

(e) 4 Limited use of interrupts

SIL minimo: 3

(f) 5 Limited use of pointers

SIL minimo: 3

(g) 6 Limited use of recursion

SIL minimo: 3

165

Page 184: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE C. QUESTIONARIO D’ESEMPIO

(h) 7 No unconditional jumps in programs in higher level languages

SIL minimo: 2

13. Which tecniques are you using for dynamic analysis and testing?

(a) 1 Test case execution from boundary value analysis

SIL minimo: 2

(b) 2 Test case execution from error guessing

SIL minimo: Never

(c) 3 Test case execution from error seeding

SIL minimo: Never

(d) 4 Performance modelling

SIL minimo: 4

(e) 5 Equivalence classes and input partition testing

SIL minimo: 4

(f) 6 Structure-based testing

SIL minimo: 3

14. Which tecniques are you using for functional and black-box testing?

(a) 1 Test case execution from cause consequence diagrams

SIL minimo: Never

(b) 2 Prototyping/animation

SIL minimo: Never

(c) 3 Boundary value analysis

SIL minimo: 2

(d) 4 Equivalence classes and input partition testing

SIL minimo: 2

(e) 5 Process simulation

SIL minimo: Never

15. Which tecniques are you using to analyze failures?

(a) 1a Cause consequence diagrams

SIL minimo: Never

(b) 1b Event tree analysis

SIL minimo: Never

Esclude:

166

Page 185: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE C. QUESTIONARIO D’ESEMPIO

i. 1a Cause consequence diagrams

(c) 2 Fault tree analysis

SIL minimo: 3

(d) 3 Failure modes, effects and criticality analysis

SIL minimo: 3

(e) 4 Monte-Carlo simulation

SIL minimo: Never

16. Which modelling tecniques are you using?

(a) 1 Data flow diagrams

SIL minimo: Never

(b) 2 Finite state machines

SIL minimo: 4

(c) 3 Formal methods

SIL minimo: 4

(d) 4 Performance modelling

SIL minimo: 4

(e) 5 Time Petri nets

SIL minimo: 4

(f) 6 Prototyping/animation

SIL minimo: Never

(g) 7 Structure diagrams

SIL minimo: 4

17. Which tecniques are you using to test performaces?

(a) 1 Avalanche/stress testing

SIL minimo: 3

(b) 2 Response timings and memory constraints

(c) 3 Performance requirements

18. Which semi-formal methods are you using?

(a) 1 Logic/function block diagrams

SIL minimo: 3

167

Page 186: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE C. QUESTIONARIO D’ESEMPIO

(b) 2 Sequence diagrams

SIL minimo: 3

(c) 3 Data flow diagrams

SIL minimo: Never

(d) 4 Finite state machines/state transition diagrams

SIL minimo: 3

(e) 5 Time Petri nets

SIL minimo: 3

(f) 6 Decision/truth tables

SIL minimo: 3

19. Which tecniques are you using for static analysis?

(a) 1 Boundary value analysis

SIL minimo: 3

(b) 2 Checklists

SIL minimo: Never

(c) 3 Control flow analysis

SIL minimo: 2

(d) 4 Data flow analysis

SIL minimo: 2

(e) 5 Error guessing

SIL minimo: Never

(f) 6 Fagan inspections

SIL minimo: 4

(g) 7 Sneak circuit analysis

SIL minimo: Never

(h) 8 Symbolic execution

SIL minimo: 3

(i) 9 Walk-throughs/design reviews

20. Which modular approch are you using?

(a) 1 Software module size limit

(b) 2 Information hiding/encapsulation

SIL minimo: 2

168

Page 187: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE C. QUESTIONARIO D’ESEMPIO

(c) 3 Parameter number limit

SIL minimo: Never

(d) 4 One entry/one exit point in subroutines and functions

(e) 5 Fully defined interface

21. What is the size of the development team?

(a) Less than 4 developers (small team)

(b) Between 4 and 8 developers (medium team)

(c) More than 8 developers (big team)

22. In which country the product will be sold?

(a) Western Europe

Alternative di secondo livello:

i. Andorra, Principality of

ii. Austria, Republic of

iii. Belgium, Kingdom of

iv. Denmark, Kingdom of

v. Finland, Republic of

vi. France, French Republic

vii. Germany, Federal Republic of

viii. Greece, Hellenic Republic

ix. Iceland, Republic of

x. Ireland

xi. Italy, Italian Republic

xii. Liechtenstein, Principality of

xiii. Luxembourg, Grand Duchy of

xiv. Malta, Republic of

xv. Monaco, Principality of

xvi. Netherlands, Kingdom of the

xvii. Norway, Kingdom of

xviii. Portugal, Portuguese Republic

xix. San Marino, Republic of

xx. Spain, Kingdom of

169

Page 188: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE C. QUESTIONARIO D’ESEMPIO

xxi. Sweden, Kingdom of

xxii. Switzerland, Swiss Confederation

xxiii. United Kingdom of Great Britain & Northern Ireland

(b) Eastern Europe

Alternative di secondo livello:

i. Albania, Republic of

ii. Belarus, Republic of

iii. Bosnia and Herzegovina

iv. Bulgaria, Republic of

v. Croatia, Republic of

vi. Czech Republic

vii. Estonia, Republic of

viii. Hungary, Republic of

ix. Latvia, Republic of

x. Lithuania, Republic of

xi. Macedonia, Republic of

xii. Moldova, Republic of

xiii. Montenegro, Republic of

xiv. Poland, Republic of

xv. Romania

xvi. Russian Federation

xvii. Serbia, Republic of

xviii. Slovakia (Slovak Republic)

xix. Slovenia, Republic of

xx. Svalbard & Jan Mayen Islands

xxi. Ukraine

(c) North America

Alternative di secondo livello:

i. Anguilla

ii. Antigua and Barbuda

iii. Aruba

iv. Bahamas, Commonwealth of the

v. Barbados

170

Page 189: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE C. QUESTIONARIO D’ESEMPIO

vi. Belize

vii. Bermuda

viii. British Virgin Islands

ix. Canada

x. Cayman Islands

xi. Costa Rica, Republic of

xii. Cuba, Republic of

xiii. Dominica, Commonwealth of

xiv. Dominican Republic

xv. El Salvador, Republic of

xvi. Greenland

xvii. Grenada

xviii. Guadeloupe

xix. Guatemala, Republic of

xx. Haiti, Republic of

xxi. Honduras, Republic of

xxii. Jamaica

xxiii. Martinique

xxiv. Mexico, United Mexican States

xxv. Montserrat

xxvi. Netherlands Antilles

xxvii. Nicaragua, Republic of

xxviii. Panama, Republic of

xxix. Puerto Rico, Commonwealth of

xxx. Saint Barthelemy

xxxi. Saint Kitts and Nevis, Federation of

xxxii. Saint Lucia

xxxiii. Saint Martin

xxxiv. Saint Pierre and Miquelon

xxxv. Saint Vincent and the Grenadines

xxxvi. Trinidad and Tobago, Republic of

xxxvii. Turks and Caicos Islands

xxxviii. United States of America

171

Page 190: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE C. QUESTIONARIO D’ESEMPIO

xxxix. United States Virgin Islands

(d) South America

Alternative di secondo livello:

i. Argentina, Argentine Republic

ii. Bolivia, Republic of

iii. Brazil, Federative Republic of

iv. Chile, Republic of

v. Colombia, Republic of

vi. Ecuador, Republic of

vii. Falkland Islands (Malvinas)

viii. French Guiana

ix. Guyana, Co-operative Republic of

x. Paraguay, Republic of

xi. Peru, Republic of

xii. Suriname, Republic of

xiii. Uruguay, Eastern Republic of

xiv. Venezuela, Bolivarian Republic of

(e) Asia

(f) Africa

(g) Australia

23. What is the size of your company?

(a) Small (fewer than 50 employees)

(b) Medium (between 51 and 100 employees)

(c) Large (more than 100 employees)

24. You should specify the links between concepts Source and Requirement

25. You should specify the links between concepts OperatingMode and Designat-

edState

26. You should specify the links between concepts OperatingMode and Require-

ment

27. You should specify the links between concepts SafetyRequirement and Safety-

IntegrityLevel

172

Page 191: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

Appendice DCodice sorgente di

EvidenceAgreement

D.1 Package it.uniroma2.norge.common

D.1.1 Classe AnswerStatus.java

package i t . uniroma2 . norge . common ;

import java . u t i l . LinkedHashMap ;

public f ina l class AnswerStatus {public stat ic f ina l St r ing PROPOSED = ”Proposed” ;

public stat ic f ina l St r ing ACCEPTED = ”Agreed” ;

public stat ic f ina l St r ing REJECTED = ” Rejected ” ;

public stat ic f ina l St r ing PART AGREED = ” P a r t i a l l y agreed ” ;

10public stat ic St r ing min ( St r ing s1 , S t r ing s2 ) {

LinkedHashMap<Str ing , Integer> l e v e l = new LinkedHashMap<Str ing , Integer >() ;

l e v e l . put ( AnswerStatus .PROPOSED, 0) ;

l e v e l . put ( AnswerStatus .PART AGREED, 2) ;

l e v e l . put ( AnswerStatus .REJECTED, 3) ;

l e v e l . put ( AnswerStatus .ACCEPTED, 4) ;

i f ( s1 == null | | ! l e v e l . containsKey ( s1 ) )

return PROPOSED;

i f ( s2 == null | | ! l e v e l . containsKey ( s2 ) )

20 return PROPOSED;

for ( S t r ing k : l e v e l . keySet ( ) ) {i f ( s1 . equa l s ( k ) | | s2 . equa l s ( k ) )

return k ;

}return PROPOSED;

}}

173

Page 192: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.1.2 Classe DeliverableStatus.java

package i t . uniroma2 . norge . common ;

public f ina l class D e l i v e r a b l e S t a t u s {public stat ic f ina l St r ing PROPOSED = ”Proposed” ;

public stat ic f ina l St r ing ACCEPTED = ”Agreed” ;

public stat ic f ina l St r ing PART AGREED = ” P a r t i a l l y agreed ” ;

public stat ic f ina l St r ing REJECTED = ” Rejected ” ;

}

D.1.3 Classe DeliverableTypes.java

package i t . uniroma2 . norge . common ;

public f ina l class Del iverab leTypes {public stat ic f ina l St r ing DOCUMENT = ”Document” ;

public stat ic f ina l St r ing ACTIVITY = ” Act iv i ty ” ;

public stat ic f ina l St r ing VARIOUS = ” var i ous ” ;

public f ina l class DocTypes1 {public stat ic f ina l St r ing ONSITE = ”On−s i t e ” ;

10 public stat ic f ina l St r ing OFFSITE = ”Off−s i t e ” ;

}

public f ina l class DocTypes2 {public stat ic f ina l St r ing NORMAL = ” f o r v e r i f i c a t i o n ” ;

public stat ic f ina l St r ing INFO = ” f o r in fo rmat ion ” ;

}}

D.1.4 Classe DocumentStatus.java

package i t . uniroma2 . norge . common ;

public f ina l class DocumentStatus {public stat ic f ina l St r ing PROPOSED SUPPLIER = ”Proposed by s u p p l i e r ” ;

public stat ic f ina l St r ing PROPOSED CERTIFIER = ”Proposed by c e r t i f i e r ” ;

public stat ic f ina l St r ing ACCEPTED = ”Accepted” ;

public stat ic f ina l St r ing DELETED = ” Deleted ” ;

public stat ic f ina l St r ing PROPOSED DELETION SUPPLIER = ”Withdrawn proposed by

s u p p l i e r ” ;

public stat ic f ina l St r ing PROPOSED DELETION CERTIFIER = ”Withdrawn proposed by

c e r t i f i e r ” ;

10 public stat ic f ina l St r ing WITHDRAWN = ”Withdrawn” ;

}

D.1.5 Classe QuestionStatus.java

174

Page 193: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

package i t . uniroma2 . norge . common ;

import java . u t i l . LinkedHashMap ;

public f ina l class Quest ionStatus {public stat ic f ina l St r ing TO SPECIFY = ”To s p e c i f y ” ;

public stat ic f ina l St r ing YET TO ANALYZE = ”Waiting f o r agreement ” ;

public stat ic f ina l St r ing ACCEPTED = ”Agreed” ;

public stat ic f ina l St r ing REJECTED = ” Rejected ” ;

10 public stat ic f ina l St r ing PART AGREED = ” P a r t i a l l y agreed ” ;

public stat ic St r ing min ( St r ing s1 , S t r ing s2 ) {LinkedHashMap<Str ing , Integer> l e v e l = new LinkedHashMap<Str ing , Integer >() ;

l e v e l . put ( Quest ionStatus . TO SPECIFY, 0) ;

l e v e l . put ( Quest ionStatus .YET TO ANALYZE, 1) ;

l e v e l . put ( Quest ionStatus .PART AGREED, 2) ;

l e v e l . put ( Quest ionStatus .REJECTED, 3) ;

l e v e l . put ( Quest ionStatus .ACCEPTED, 4) ;

i f ( s1 != null && s2 == null && l e v e l . containsKey ( s1 ) )

20 return s1 ;

i f ( s2 != null && s1 == null && l e v e l . containsKey ( s2 ) )

return s2 ;

i f ( s1 == null | | ! l e v e l . containsKey ( s1 ) )

return TO SPECIFY;

i f ( s2 == null | | ! l e v e l . containsKey ( s2 ) )

return TO SPECIFY;

for ( S t r ing k : l e v e l . keySet ( ) ) {i f ( s1 . equa l s ( k ) | | s2 . equa l s ( k ) )

return k ;

30 }return TO SPECIFY;

}}

D.1.6 Classe RoleTypes.java

package i t . uniroma2 . norge . common ;

public f ina l class RoleTypes {public stat ic f ina l St r ing ADMIN = ”admin” ;

public stat ic f ina l St r ing SUPPLIER = ” s u p p l i e r ” ;

public stat ic f ina l St r ing CERTIFIER = ” c e r t i f i e r ” ;

}

D.2 Package it.uniroma2.norge.controller

D.2.1 Classe AgreementCtrl.java

175

Page 194: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

package i t . uniroma2 . norge . c o n t r o l l e r ;

import i t . uniroma2 . norge . common . D e l i v e r a b l e S t a t u s ;

import i t . uniroma2 . norge . model . DefDel iverablesManager ;

import i t . uniroma2 . norge . model . Del iverablesManager ;

import i t . uniroma2 . norge . model . AgreementManager ;

import i t . uniroma2 . norge . model . jpa . D e f a u l t D e l i v e r a b l e ;

import i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

10 import i t . uniroma2 . norge . web . AgreementUI ;

import i t . uniroma2 . norge . web . Tes iwebAppl icat ion ;

import java . u t i l . L i s t ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . u i . MenuBar .Command;

import com . vaadin . u i . MenuBar . MenuItem ;

20 public class AgreementCtrl implements Command, Property . ValueChangeListener {

private TesiwebAppl icat ion appl ;

private AgreementManager projectMngr ;

private AgreementUI prjUI ;

public AgreementCtrl ( f ina l TesiwebAppl icat ion appl ) {projectMngr = new AgreementManager ( ) ;

30 this . appl = appl ;

prjUI = new AgreementUI ( this . appl ) ;

}

public List<Agreement> getLis tData ( ) {return projectMngr . v iewAl l ( ) ;

}

@Override

public void menuSelected ( MenuItem se l e c t ed I t em ) {40 St r ing item = null ;

i f ( s e l e c t ed I t em != null )

item = se l e c t ed I t em . getText ( ) ;

appl . showNot i f i c a t i on ( item ) ;

appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

i f ( item != null && item . equa l s ( ”Add agreement ” ) )

prjUI . projectsAdd ( ) ;

else

prjUI . p r o j e c t s L i s t ( ) ;

}50

@Override

public void valueChange ( ValueChangeEvent event ) {prjUI . p r o j e c t D e t a i l s ( ) ;

}

public void c r e a t e ( Agreement p r j ) throws SaveException {

176

Page 195: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

projectMngr . savePro j e c t ( p r j ) ;

DefDel iverablesManager defDelivMngr = new DefDel iverablesManager ( ) ;

Del iverablesManager dDelivMngr = new Del iverablesManager ( ) ;

60 List<Defau l tDe l i v e rab l e> l = defDelivMngr . v iewAl l ( ) ;

for ( D e f a u l t D e l i v e r a b l e d : l ) {D e l i v e r a b l e d1 = new D e l i v e r a b l e ( ) ;

d1 . s e t P r o j e c t ( p r j ) ;

d1 . setName (d . getName ( ) ) ;

d1 . s e t D e s c r i p t i o n (d . g e tDe s c r i p t i on ( ) ) ;

d1 . setType (d . getType ( ) ) ;

d1 . setSubtype1 (d . getSubtype1 ( ) ) ;

d1 . setSubtype2 (d . getSubtype2 ( ) ) ;

d1 . setApprova lStatus ( D e l i v e r a b l e S t a t u s .PROPOSED) ;

70 dDelivMngr . s a v e D e l i v e r a b l e ( d1 ) ;

}prjUI . p r o j e c t s L i s t ( ) ;

}

public void update ( Agreement p r j ) throws SaveException {projectMngr . savePro j e c t ( p r j ) ;

prjUI . p r o j e c t D e t a i l s ( ) ;

}

80 }

D.2.2 Classe AssignmentsCtrl.java

package i t . uniroma2 . norge . c o n t r o l l e r ;

import i t . uniroma2 . norge . model . AssignmentManager ;

import i t . uniroma2 . norge . model . AgreementManager ;

import i t . uniroma2 . norge . model . jpa . Assignment ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

import i t . uniroma2 . norge . model . jpa . Role ;

import i t . uniroma2 . norge . web . AssignmentUI ;

import i t . uniroma2 . norge . web . Tes iwebAppl icat ion ;

10import java . u t i l . L i s t ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

public class AssignmentsCtr l

{

private TesiwebAppl icat ion appl ;

20private AssignmentManager assignmentMngr ;

private AgreementManager projectMngr ;

private Agreement r e f e r e n c e P r o j e c t ;

private Assignment re fe renceAss ignment ;

177

Page 196: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private AssignmentUI ass ignUI ;

30public AssignmentsCtr l ( f ina l TesiwebAppl icat ion appl )

{projectMngr = new AgreementManager ( ) ;

assignmentMngr = new AssignmentManager ( ) ;

this . appl = appl ;

ass ignUI= new AssignmentUI ( appl ) ;

i f ( getRo le s ( ) == null | | getRo le s ( ) . s i z e ( ) <= 0)

in i tDatabase ( ) ;

}40

private void i n i tDatabase ( ) {Role r ;

r = new Role ( ) ;

r . setCode ( ”admin” ) ;

r . s e tRo l eDe s c r i p t i on ( ” Administrator ” ) ;

assignmentMngr . saveRole ( r ) ;

r = new Role ( ) ;

r . setCode ( ” prjadmin ” ) ;

r . s e tRo l eDe s c r i p t i on ( ” Pro j e c t admin i s t ra to r ” ) ;

50 assignmentMngr . saveRole ( r ) ;

r = new Role ( ) ;

r . setCode ( ” s u p p l i e r ” ) ;

r . s e tRo l eDe s c r i p t i on ( ” Supp l i e r ” ) ;

assignmentMngr . saveRole ( r ) ;

r = new Role ( ) ;

r . setCode ( ” c e r t i f i e r ” ) ;

r . s e tRo l eDe s c r i p t i on ( ” C e r t i f i e r ” ) ;

assignmentMngr . saveRole ( r ) ;

}60

public List<Assignment> getLis tData ( )

{projectMngr . r e f r e s h ( r e f e r e n c e P r o j e c t ) ;

return r e f e r e n c e P r o j e c t . getAssignments ( ) ;

}

public void viewAl l ( Agreement p r j )

{r e f e r e n c e P r o j e c t = pr j ;

70 ass ignUI . as s ignmentL i s t ( ) ;

}

public void addAssignment ( )

{ass ignUI . assignmentAdd ( ) ;

}

public void c r e a t e ( Assignment a s s i g n ) throws SaveException

{80 a s s i g n . s e t P r o j e c t ( r e f e r e n c e P r o j e c t ) ;

assignmentMngr . saveAssignment ( a s s i g n ) ;

projectMngr . r e f r e s h ( r e f e r e n c e P r o j e c t ) ;

ass ignUI . as s ignmentL i s t ( ) ;

178

Page 197: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

public void update ( Assignment a s s i g n ) throws SaveException

{assignmentMngr . saveAssignment ( a s s i g n ) ;

90 }

private class AssignmentSe lected implements Property . ValueChangeListener

{

@Override

public void valueChange ( ValueChangeEvent event )

{re f e renceAss ignment = ( Assignment ) ass ignUI . ass ignmentTable . getValue ( ) ;

ass ignUI . a s s i gnmentDeta i l s ( ) ;

100 }}

public AssignmentSe lected getAss ignmentSe lected ( )

{return new AssignmentSe lected ( ) ;

}

public List<Role> getRo le s ( )

{110 return assignmentMngr . v iewAl lRoles ( ) ;

}

}

D.2.3 Classe DefDeliverableCtrl.java

package i t . uniroma2 . norge . c o n t r o l l e r ;

import i t . uniroma2 . norge . model . DefDel iverablesManager ;

import i t . uniroma2 . norge . model . jpa . D e f a u l t D e l i v e r a b l e ;

import i t . uniroma2 . norge . web . De fau l tDe l i v e rab l e sUI ;

import i t . uniroma2 . norge . web . Tes iwebAppl icat ion ;

import java . u t i l . L i s t ;

10 import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . u i . MenuBar .Command;

import com . vaadin . u i . MenuBar . MenuItem ;

public class De fDe l i v e r ab l eCt r l implements Command,

Property . ValueChangeListener {

private TesiwebAppl icat ion appl ;

20 private DefDel iverablesManager delivMngr ;

179

Page 198: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private Defau l tDe l i v e rab l e sUI u i ;

public De fDe l i v e r ab l eCt r l ( Tes iwebAppl icat ion appl ) {this . appl = appl ;

u i = new Defau l tDe l i v e rab l e sUI ( this . appl ) ;

del ivMngr = new DefDel iverablesManager ( ) ;

}

30 @Override

public void valueChange ( ValueChangeEvent event ) {i f ( u i . d e l i v sTab l e == null ) {

System . out . p r i n t l n ( ” Tabel la non e s i s t e 2” ) ;

return ;

}}

@Override

public void menuSelected ( MenuItem se l e c t ed I t em ) {40 St r ing item = se l e c t ed I t em . getText ( ) ;

appl . showNot i f i c a t i on ( item ) ;

appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

i f ( item != null && item . equa l s IgnoreCase ( ”add user ” ) )

u i . delivAdd ( ) ;

else

ui . d e l i v e r a b l e s L i s t A l l ( ) ;

}

50 public List<Defau l tDe l i v e rab l e> getLis tData ( ) {return delivMngr . v iewAl l ( ) ;

}

public void c r e a t e ( D e f a u l t D e l i v e r a b l e d) throws SaveException {delivMngr . s a v e D e l i v e r a b l e (d) ;

u i . d e l i v e r a b l e s L i s t A l l ( ) ;

}

public void update ( D e f a u l t D e l i v e r a b l e d) throws SaveException {60 delivMngr . s a v e D e l i v e r a b l e (d) ;

u i . d e l i v e r a b l e s L i s t A l l ( ) ;

}

public void r e f r e s h ( D e f a u l t D e l i v e r a b l e d e f a u l t D e l i v e r a b l e ) {i f ( d e f a u l t D e l i v e r a b l e != null )

delivMngr . r e f r e s h ( d e f a u l t D e l i v e r a b l e ) ;

}}

D.2.4 Classe DeliverableCtrl.java

package i t . uniroma2 . norge . c o n t r o l l e r ;

import i t . uniroma2 . norge . common . D e l i v e r a b l e S t a t u s ;

import i t . uniroma2 . norge . common . RoleTypes ;

180

Page 199: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import i t . uniroma2 . norge . model . Del iverablesManager ;

import i t . uniroma2 . norge . model . AgreementManager ;

import i t . uniroma2 . norge . model . UserManager ;

import i t . uniroma2 . norge . model . jpa . AnswerSet ;

import i t . uniroma2 . norge . model . jpa . Evidence ;

10 import i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e ;

import i t . uniroma2 . norge . model . jpa . De l ive rab l eEv idence ;

import i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e H i s t o r y ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

import i t . uniroma2 . norge . model . jpa . Role ;

import i t . uniroma2 . norge . model . jpa . User ;

import i t . uniroma2 . norge . web . De fau l tDe l i v e rab l e sUI ;

import i t . uniroma2 . norge . web . De l i v e rab l e sUI ;

import i t . uniroma2 . norge . web . Tes iwebAppl icat ion ;

20 import java . i o . S e r i a l i z a b l e ;

import java . u t i l . ArrayList ;

import java . u t i l . Date ;

import java . u t i l . L inkedLis t ;

import java . u t i l . L i s t ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . u i . MenuBar .Command;

import com . vaadin . u i . MenuBar . MenuItem ;

30public class D e l i v e r a b l e C t r l implements S e r i a l i z a b l e , Command {

private Del iverablesManager de l ive rab l e sMngr ;

private TesiwebAppl icat ion appl ;

private De l ive rab l e sUI d e l i v e r a b l e U I ;

private Defau l tDe l i v e rab l e sUI de fDe l i v e rab l eUI ;

protected Agreement r e f e r e n c e P r o j e c t ;

40 protected D e l i v e r a b l e r e f e r e n c e D e l i v e r a b l e ;

public D e l i v e r a b l e C t r l ( f ina l TesiwebAppl icat ion appl ) {super ( ) ;

de l ive rab l e sMngr = new Del iverablesManager ( ) ;

this . appl = appl ;

d e l i v e r a b l e U I = new De l ive rab l e sUI ( appl ) ;

d e fDe l i v e rab l eUI = new Defau l tDe l i v e rab l e sUI ( appl ) ;

}

50 public Command getMenu ( ) {return new Command( ) {

@Override

public void menuSelected ( MenuItem se l e c t ed I t em ) {appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

LoggedUser user = ( LoggedUser ) appl . getUser ( ) ;

{d e l i v e r a b l e U I . p r o j e c t s L i s t ( ) ;

L i s t<Agreement> tmp = user . p ro j e c t sForRo l e ( null ) ;

i f (tmp . s i z e ( ) == 1) {60 d e l i v e r a b l e U I . p r o j e c t L i s t . s e l e c t (tmp . get (0 ) ) ;

181

Page 200: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

r e f e r e n c e P r o j e c t = tmp . get (0 ) ;

User user2 = ( ( LoggedUser ) appl . getUser ( ) ) . getUserObj ( ) ;

Role r o l e = UserManager . getRo leForPro jec t ( user2 ,

r e f e r e n c e P r o j e c t ) ;

boolean i s S u p p l i e r = ( r o l e . g e tRo l eDesc r ip t i on ( )

. equa l s IgnoreCase ( RoleTypes .SUPPLIER) ) ;

d e l i v e r a b l e U I . d e l i v e r a b l e s L i s t ( i s S u p p l i e r ) ;

}70 }

}} ;

}

private class P r jS e l e c t e d implements Property . ValueChangeListener {

@Override

public void valueChange ( ValueChangeEvent event ) {r e f e r e n c e P r o j e c t = ( Agreement ) d e l i v e r a b l e U I . p r o j e c t L i s t . getValue ( ) ;

80 User user = ( ( LoggedUser ) appl . getUser ( ) ) . getUserObj ( ) ;

Role r o l e = UserManager . getRo leForPro jec t ( user , r e f e r e n c e P r o j e c t ) ;

boolean i s S u p p l i e r = ( r o l e . g e tRo l eDesc r ip t i on ( )

. equa l s IgnoreCase ( RoleTypes .SUPPLIER) ) ;

d e l i v e r a b l e U I . d e l i v e r a b l e s L i s t ( i s S u p p l i e r ) ;

}}

public P r jS e l e c t e d g e t P r o j e c t S e l e c t e d ( ) {return new P r jS e l e c t e d ( ) ;

90 }

public List<Del ive rab l e> g e t D e l i v e r a b l e s L i s t ( ) {de l ive rab l e sMngr . r e f r e s h ( r e f e r e n c e P r o j e c t ) ;

return r e f e r e n c e P r o j e c t . g e t D e l i v e r a b l e s ( ) ;

}

public void d e l i v e r a b l e S e l e c t e d H i s t o r y ( I n t e g e r qid ) {r e f e r e n c e D e l i v e r a b l e = de l ive rab l e sMngr . g e t D e l i v e r a b l e ( qid ) ;

d e l i v e r a b l e U I . d e l i v e r a b l e D e t a i l s H i s t o r y ( ) ;

100 }

public void d e l i v e r a b l e S e l e c t e d D e t a i l s ( I n t e g e r qid ) {r e f e r e n c e D e l i v e r a b l e = de l ive rab l e sMngr . g e t D e l i v e r a b l e ( qid ) ;

User user = ( ( LoggedUser ) appl . getUser ( ) ) . getUserObj ( ) ;

Role r = UserManager . getRo leForPro jec t ( user , r e f e r e n c e P r o j e c t ) ;

i f ( r == null )

return ;

boolean i s S u p p l i e r = ( r . g e tRo l eDesc r ip t i on ( )

. equa l s IgnoreCase ( RoleTypes .SUPPLIER) ) ;

110 d e l i v e r a b l e U I . d e l i v e r a b l e D e t a i l s ( false , i s S u p p l i e r ) ;

}

public void del iverableEvidenceMapping ( I n t e g e r qid ) {r e f e r e n c e D e l i v e r a b l e = de l ive rab l e sMngr . g e t D e l i v e r a b l e ( qid ) ;

User user = ( ( LoggedUser ) appl . getUser ( ) ) . getUserObj ( ) ;

Role r = UserManager . getRo leForPro jec t ( user , r e f e r e n c e P r o j e c t ) ;

182

Page 201: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

i f ( r == null )

return ;

boolean i s S u p p l i e r = ( r . g e tRo l eDesc r ip t i on ( )

120 . equa l s IgnoreCase ( RoleTypes .SUPPLIER) ) ;

d e l i v e r a b l e U I . de l iverab leMapping ( ! i s S u p p l i e r ) ;

}

public void c r e a t e D e l i v e r a b l e ( D e l i v e r a b l e dh) throws SaveException {dh . s e t P r o j e c t ( r e f e r e n c e P r o j e c t ) ;

dh . setApprova lStatus ( D e l i v e r a b l e S t a t u s .PROPOSED) ;

de l ive rab l e sMngr . s a v e D e l i v e r a b l e (dh) ;

de l ive rab l e sMngr . r e f r e s h ( r e f e r e n c e P r o j e c t ) ;

d e l i v e r a b l e U I . d e l i v e r a b l e s L i s t ( true ) ;

130 }

public D e l i v e r a b l e g e t R e f e r e n c e D e l i v e r a b l e ( ) {i f ( r e f e r e n c e D e l i v e r a b l e != null )

de l ive rab l e sMngr . r e f r e s h ( r e f e r e n c e D e l i v e r a b l e ) ;

return r e f e r e n c e D e l i v e r a b l e ;

}

public enum Del ivAct ions {ACCEPT, REJECT, PART ACCEPT;

140 }

public List<Del ivAct ions> getAdmittedActions ( ) {User user = ( ( LoggedUser ) appl . getUser ( ) ) . getUserObj ( ) ;

Role r = UserManager . getRo leForPro jec t ( user , r e f e r e n c e P r o j e c t ) ;

LinkedList<Del ivAct ions> r e s = new LinkedList<Del ivAct ions >() ;

i f ( r == null )

return r e s ;

boolean i s S u p p l i e r = ( r . g e tRo l eDesc r ip t i on ( )

. equa l s IgnoreCase ( RoleTypes .SUPPLIER) ) ;

150 i f ( ! i s S u p p l i e r ) {i f ( r e f e r e n c e D e l i v e r a b l e . getApprovalStatus ( ) . equa l s (

D e l i v e r a b l e S t a t u s .PROPOSED) ) {r e s . add ( De l ivAct ions .ACCEPT) ;

r e s . add ( De l ivAct ions .PART ACCEPT) ;

r e s . add ( De l ivAct ions .REJECT) ;

} else i f ( r e f e r e n c e D e l i v e r a b l e . getApprovalStatus ( ) . equa l s (

D e l i v e r a b l e S t a t u s .ACCEPTED) ) {r e s . add ( De l ivAct ions .REJECT) ;

r e s . add ( De l ivAct ions .PART ACCEPT) ;

160 } else i f ( r e f e r e n c e D e l i v e r a b l e . getApprovalStatus ( ) . equa l s (

D e l i v e r a b l e S t a t u s .REJECTED) ) {r e s . add ( De l ivAct ions .ACCEPT) ;

r e s . add ( De l ivAct ions .PART ACCEPT) ;

} else i f ( r e f e r e n c e D e l i v e r a b l e . getApprovalStatus ( ) . equa l s (

D e l i v e r a b l e S t a t u s .PART AGREED) ) {r e s . add ( De l ivAct ions .ACCEPT) ;

r e s . add ( De l ivAct ions .REJECT) ;

}}

170 return r e s ;

}

183

Page 202: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public List<Del ivAct ions> getAdmittedAct ionsDel ivSet ( ) {User user = ( ( LoggedUser ) appl . getUser ( ) ) . getUserObj ( ) ;

Role r = UserManager . getRo leForPro jec t ( user , r e f e r e n c e P r o j e c t ) ;

LinkedList<Del ivAct ions> r e s = new LinkedList<Del ivAct ions >() ;

i f ( r == null )

return r e s ;

boolean i s S u p p l i e r = ( r . g e tRo l eDesc r ip t i on ( )

180 . equa l s IgnoreCase ( RoleTypes .SUPPLIER) ) ;

S t r ing now = r e f e r e n c e P r o j e c t . g e t D e l i v e r a b l e s S t a t u s ( ) ;

i f ( ! i s S u p p l i e r ) {i f (now == null | | now . equa l s ( ”” )

| | now . equa l s ( D e l i v e r a b l e S t a t u s .PROPOSED) ) {r e s . add ( De l ivAct ions .ACCEPT) ;

r e s . add ( De l ivAct ions .REJECT) ;

} else i f (now . equa l s ( D e l i v e r a b l e S t a t u s .ACCEPTED) )

r e s . add ( De l ivAct ions .REJECT) ;

else i f (now . equa l s ( D e l i v e r a b l e S t a t u s .REJECTED) ) {190 r e s . add ( De l ivAct ions .ACCEPT) ;

}}return r e s ;

}

public void saveDer ivab l eH i s to ry ( D e l i v e r a b l e H i s t o r y h i s t ) {

}

200 public void saveDel iverablesComments ( ArrayList<Del iverab leEvidence> dats ) {for ( De l ive rab l eEv idence de : dats ) {

try {de l ive rab l e sMngr . saveDe l ive rab l eEv idence ( de ) ;

} catch ( SaveException e ) {}

}}

public void applyAction ( De l ivAct ions act , D e l i v e r a b l e H i s t o r y dh)

210 throws SaveException {User user = ( ( LoggedUser ) appl . getUser ( ) ) . getUserObj ( ) ;

Role r o l e = UserManager . getRo leForPro jec t ( user , r e f e r e n c e P r o j e c t ) ;

boolean i s S u p p l i e r = ( r o l e . g e tRo l eDesc r ip t i on ( )

. equa l s IgnoreCase ( RoleTypes .SUPPLIER) ) ;

dh . s e t D e l i v e r a b l e ( r e f e r e n c e D e l i v e r a b l e ) ;

dh . setModtime (new Date ( ) ) ;

dh . se tUser ( user ) ;

switch ( act ) {case ACCEPT:

220 i f ( r e f e r e n c e D e l i v e r a b l e . getApprovalStatus ( ) . equa l s (

D e l i v e r a b l e S t a t u s .PROPOSED)

| | r e f e r e n c e D e l i v e r a b l e . getApprovalStatus ( ) . equa l s (

D e l i v e r a b l e S t a t u s .REJECTED) ) {r e f e r e n c e D e l i v e r a b l e

. setApprova lStatus ( D e l i v e r a b l e S t a t u s .ACCEPTED) ;

i f ( i s S u p p l i e r ) {dh . se tRo le ( ” Supp l i e r ” ) ;

} else {

184

Page 203: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

dh . se tRo le ( ” C e r t i f i e r ” ) ;

230 }dh . se tAct ion ( ” Accepts the proposa l ” ) ;

}break ;

case REJECT:

i f ( r e f e r e n c e D e l i v e r a b l e . getApprovalStatus ( ) . equa l s (

D e l i v e r a b l e S t a t u s .PROPOSED)

| | r e f e r e n c e D e l i v e r a b l e . getApprovalStatus ( ) . equa l s (

D e l i v e r a b l e S t a t u s .ACCEPTED) ) {r e f e r e n c e D e l i v e r a b l e

240 . s e tApprova lStatus ( D e l i v e r a b l e S t a t u s .REJECTED) ;

i f ( i s S u p p l i e r ) {dh . se tRo le ( ” Supp l i e r ” ) ;

} else {dh . se tRo le ( ” C e r t i f i e r ” ) ;

}dh . se tAct ion ( ” Reject the proposa l ” ) ;

}break ;

}250 dh . setNewState ( r e f e r e n c e D e l i v e r a b l e . getApprovalStatus ( ) ) ;

de l ive rab l e sMngr . s a v e D e l i v e r a b l e ( r e f e r e n c e D e l i v e r a b l e ) ;

de l ive rab l e sMngr . s a v e D e l i v e r a b l e H i s t (dh) ;

de l ive rab l e sMngr . r e f r e s h ( r e f e r e n c e P r o j e c t ) ;

de l ive rab l e sMngr . r e f r e s h ( r e f e r e n c e D e l i v e r a b l e ) ;

d e l i v e r a b l e U I . d e l i v e r a b l e s L i s t ( i s S u p p l i e r ) ;

d e l i v e r a b l e U I . d e l i v e r a b l e D e t a i l s ( false , i s S u p p l i e r ) ;

}

public St r ing ac tua lDe l i ve rab l eApprova lS ta tus ( ) {260 de l ive rab l e sMngr . r e f r e s h ( r e f e r e n c e P r o j e c t ) ;

return r e f e r e n c e P r o j e c t . g e t D e l i v e r a b l e s S t a t u s ( ) ;

}

public void applyActionDelSet ( De l ivAct ions act ) {St r ing now = r e f e r e n c e P r o j e c t . g e t D e l i v e r a b l e s S t a t u s ( ) ;

AgreementManager prjMngr = new AgreementManager ( ) ;

switch ( act ) {case ACCEPT:

i f (now == null | | now . equa l s ( ”” )

270 | | now . equa l s ( D e l i v e r a b l e S t a t u s .PROPOSED)

| | now . equa l s ( D e l i v e r a b l e S t a t u s .REJECTED) ) {r e f e r e n c e P r o j e c t

. s e t D e l i v e r a b l e s S t a t u s ( D e l i v e r a b l e S t a t u s .ACCEPTED) ;

}break ;

case REJECT:

i f (now . equa l s ( D e l i v e r a b l e S t a t u s .PROPOSED)

| | now . equa l s ( D e l i v e r a b l e S t a t u s .ACCEPTED) ) {r e f e r e n c e P r o j e c t

280 . s e t D e l i v e r a b l e s S t a t u s ( D e l i v e r a b l e S t a t u s .REJECTED) ;

}break ;

}try {

185

Page 204: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

prjMngr . savePro j e c t ( r e f e r e n c e P r o j e c t ) ;

de l ive rab l e sMngr . r e f r e s h ( r e f e r e n c e P r o j e c t ) ;

} catch ( SaveException e ) {}d e l i v e r a b l e U I . d e l i v e r a b l e s L i s t ( fa l se ) ;

290 }

public St r ing ge tRe f e r encePro j e c t ( ) {return r e f e r e n c e P r o j e c t . getDeliverablesComment ( ) ;

}

public void saveDerivablesSetComment ( S t r ing doc ) {AgreementManager p r j = new AgreementManager ( ) ;

doc = doc != null ? doc : ”” ;

r e f e r e n c e P r o j e c t . setDel iverablesComment ( doc ) ;

300 try {pr j . s avePro j e c t ( r e f e r e n c e P r o j e c t ) ;

p r j . r e f r e s h ( r e f e r e n c e P r o j e c t ) ;

} catch ( SaveException e ) {}d e l i v e r a b l e U I . showDeliverablesComment ( fa l se ) ;

}

public List<Evidence> ge tEv idence sL i s t ( ) {List<Evidence> r e s = new ArrayList<Evidence >() ;

310 int s i l q i d = r e f e r e n c e P r o j e c t . ge tQues t i onna i r e ( ) . g e tS i lQue s t i on ( )

. getQuest ionId ( ) ;

for ( AnswerSet a : r e f e r e n c e P r o j e c t . getAnswerSets ( ) ) {for ( Evidence aa : a . getAnswsetAnsws ( ) )

i f ( aa . getResponse ( ) . equa l s IgnoreCase ( ” yes ” )

&& aa . getAlternat iveAnswer ( ) . getQuest ion ( ) != null )

i f ( aa . getAlternat iveAnswer ( ) . getQuest ion ( ) . getQuest ionId ( ) != s i l q i d )

r e s . add ( aa ) ;

}return r e s ;

320 }

public Del ive rab l eEv idence ge tDe l i v e rab l eEv idence ( D e l i v e r a b l e d ,

Evidence aa ) {return de l ive rab l e sMngr . ge tDe l i v e rab l eEv idence (d , aa ) ;

}

public void s a v e D e l i v e r a b l e s ( D e l i v e r a b l e d e l i ) {try {

de l ive rab l e sMngr . s a v e D e l i v e r a b l e ( d e l i ) ;

330 } catch ( SaveException e ) {}d e l i v e r a b l e S e l e c t e d D e t a i l s ( d e l i . g e t D e l i v e r a b l e I d ( ) ) ;

}

@Override

public void menuSelected ( MenuItem se l e c t ed I t em ) {appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

de fDe l i v e rab l eUI . d e l i v e r a b l e s L i s t A l l ( ) ;

}340

186

Page 205: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void r e f r e s h ( D e l i v e r a b l e d) {de l ive rab l e sMngr . r e f r e s h (d) ;

}}

D.2.5 Classe DocumentCtrl.java

package i t . uniroma2 . norge . c o n t r o l l e r ;

import i t . uniroma2 . norge . common . DocumentStatus ;

import i t . uniroma2 . norge . common . RoleTypes ;

import i t . uniroma2 . norge . model . DocumentsManager ;

import i t . uniroma2 . norge . model . UserManager ;

import i t . uniroma2 . norge . model . jpa . Document ;

import i t . uniroma2 . norge . model . jpa . DocumentHistory ;

import i t . uniroma2 . norge . model . jpa . Mpackage ;

10 import i t . uniroma2 . norge . model . jpa . Agreement ;

import i t . uniroma2 . norge . model . jpa . Role ;

import i t . uniroma2 . norge . model . jpa . User ;

import i t . uniroma2 . norge . web . DocumentsUI ;

import i t . uniroma2 . norge . web . Tes iwebAppl icat ion ;

import java . i o . ByteArrayInputStream ;

import java . i o . ByteArrayOutputStream ;

import java . i o . F i l e ;

import java . i o . Fi le InputStream ;

20 import java . i o . FileNotFoundException ;

import java . i o . FileOutputStream ;

import java . i o . IOException ;

import java . i o . InputStream ;

import java . i o . OutputStream ;

import java . i o . S e r i a l i z a b l e ;

import java . u t i l . ArrayList ;

import java . u t i l . Calendar ;

import java . u t i l . Date ;

import java . u t i l . HashMap ;

30 import java . u t i l . L inkedLis t ;

import java . u t i l . L i s t ;

import com . i t e x t p d f . t ex t . DocumentException ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . t e rmina l . StreamResource ;

import com . vaadin . t e rmina l . gwt . s e r v e r . WebApplicationContext ;

import com . vaadin . u i . MenuBar .Command;

import com . vaadin . u i . MenuBar . MenuItem ;

40public class DocumentCtrl extends F i l l o u t V a l i d a t i o n C t r l implements S e r i a l i z a b l e ,

Property . ValueChangeListener {

private TesiwebAppl icat ion appl ;

187

Page 206: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private Document referenceDocument ;

50private DocumentsUI documenUI ;

private HashMap<Integer , StreamResource> re sourceDef in i t ivePDF ;

private DocumentsManager documentsMngr ;

private StreamResource resourcePreviewPDF ;

public DocumentCtrl ( f ina l TesiwebAppl icat ion appl ) {60 super ( appl ) ;

documentsMngr = new DocumentsManager ( ) ;

this . appl = appl ;

documenUI = new DocumentsUI ( appl ) ;

}

public List<Document> getDocumentsList ( ) {documentsMngr . r e f r e s h ( r e f e r e n c e P r o j e c t ) ;

return r e f e r e n c e P r o j e c t . getDocuments ( ) ;

}70

public void createDocument ( DocumentHistory dh , f ina l boolean parte1 ,

f ina l boolean agreement , f ina l boolean mapping ,

f ina l boolean parte2 , f ina l boolean graphs , f ina l boolean historyE ,

f ina l boolean historyD , f ina l boolean context ) throws SaveException {Document doc = new Document ( ) ;

doc . s e t P r o j e c t ( r e f e r e n c e P r o j e c t ) ;

doc . s e t S t a t u s ( ”” ) ;

S t r ing fn = r e f e r e n c e P r o j e c t . getName ( ) + ” ”

+ Calendar . g e t In s tance ( ) . ge tT imeInMi l l i s ( ) ;

80 exportDef in it ivePDF ( fn , parte1 , agreement , mapping , parte2 , graphs ,

historyE , historyD , context ) ;

doc . setFi lename ( fn ) ;

doc . setPdfCreat ionDate (new Date ( ) ) ;

User user = ( ( LoggedUser ) appl . getUser ( ) ) . getUserObj ( ) ;

Role r = UserManager . getRo leForPro jec t ( user , r e f e r e n c e P r o j e c t ) ;

i f ( r != null ) {i f ( r . g e tRo l eDesc r ip t i on ( ) . equa l s IgnoreCase ( RoleTypes .SUPPLIER) ) {

doc . s e t S t a t u s ( DocumentStatus .PROPOSED SUPPLIER) ;

} else {90 doc . s e t S t a t u s ( DocumentStatus .PROPOSED CERTIFIER) ;

}doc . setModDate (new Date ( ) ) ;

dh . se tAct ion ( ”New document has been proposed ” ) ;

}documentsMngr . saveDocument ( doc ) ;

dh . setDocument ( doc ) ;

dh . setModtime (new Date ( ) ) ;

dh . setNewState ( doc . ge tSta tus ( ) ) ;

dh . se tUser ( user ) ;

100 documentsMngr . saveDocumentHist (dh) ;

referenceDocument = doc ;

documentsMngr . r e f r e s h ( referenceDocument ) ;

documentsMngr . r e f r e s h ( r e f e r e n c e P r o j e c t ) ;

188

Page 207: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

documenUI . documentsList ( ) ;

documenUI . documentDetai ls ( fa l se ) ;

}

public void menuSelected ( ) {appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

110 LoggedUser user = ( LoggedUser ) appl . getUser ( ) ;

{documenUI . p r o j e c t s L i s t ( ) ;

L i s t<Agreement> tmp = user . p ro j e c t sForRo l e ( null ) ;

i f (tmp . s i z e ( ) == 1) {documenUI . l . s e l e c t (tmp . get (0 ) ) ;

appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

r e f e r e n c e P r o j e c t = tmp . get (0 ) ;

documenUI . documentsList ( ) ;

}120 }

}

@Override

public void valueChange ( ValueChangeEvent event ) {appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

r e f e r e n c e P r o j e c t = ( Agreement ) documenUI . l . getValue ( ) ;

i n i t P r o j e c t I n f o r m a t i o n ( ) ;

documenUI . documentsList ( ) ;

}130

public void viewAl l ( Agreement p r j ) {r e f e r e n c e P r o j e c t = pr j ;

i n i t P r o j e c t I n f o r m a t i o n ( ) ;

documenUI . documentsList ( ) ;

}

public void saveDocumentHistory ( DocumentHistory h i s t ) {appl . showNot i f i c a t i on ( ”Changes have been saved ” ) ;

140 }

private byte [ ] createPDF (boolean parte1 , boolean agreement ,

boolean mapping , boolean parte2 , boolean graphs , boolean historyE ,

boolean historyD , boolean context ) throws DocumentException {int w = 410 , h = 300 ;

PDFoutput pdf = new PDFoutput ( ) ;

i f ( i s S i l Q u e s t i o n n a i r e ( ) )

pdf . s e t S i l Q u e s t i o n ( a c t u a l S i l L e v e l ( ) ) ;

L i s t<MpackageRank> datas = getListDataMpackage ( ) ;

150LinkedList<Mpackage> datas2 = new LinkedList<Mpackage>() ;

for ( MpackageRank m : datas )

datas2 . add (m. getMpackage ( ) ) ;

i f ( datas != null && datas . s i z e ( ) > 0) {for ( f ina l MpackageRank pr : datas ) {

Mpackage pkg = pr . getMpackage ( ) ;

{byte [ ] i 1 = getPlotBytes ( getStreamPieQ ( pkg , w, h) ) ;

byte [ ] i 2 = getPlotBytes ( getStreamPieA ( pkg , w, h) ) ;

189

Page 208: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

160 byte [ ] i 3 = getPlotBytes ( getStreamPieQD ( pkg , w, h) ) ;

byte [ ] i 4 = getPlotBytes ( getStreamPieD ( pkg , w, h) ) ;

pdf . addPackage ( pkg , questionMngr . viewAllAnswerSets (

r e f e r e n c e P r o j e c t , pkg ) , i1 , i2 , i3 , i 4 ) ;

}}

}byte [ ] i 1 = getPlotBytes ( getStreamPieQ (null , w, h) ) ;

byte [ ] i 2 = getPlotBytes ( getStreamPieA (null , w, h) ) ;

byte [ ] i 3 = getPlotBytes ( getStreamPieQD (null , w, h) ) ;

170 byte [ ] i 4 = getPlotBytes ( getStreamPieD (null , w, h) ) ;

return pdf . agreement ( r e f e r e n c e P r o j e c t , i1 , i2 , i3 , i4 , parte1 ,

agreement , mapping , parte2 , graphs , historyE , historyD , context ) ;

}

public void previewPDF ( f ina l boolean parte1 , f ina l boolean agreement ,

f ina l boolean mapping , f ina l boolean parte2 , f ina l boolean graphs ,

f ina l boolean historyE , f ina l boolean historyD ,

f ina l boolean context ) {180 i f ( resourcePreviewPDF == null )

resourcePreviewPDF = new StreamResource (null , ” preview . pdf ” , appl ) ;

StreamResource . StreamSource source = new StreamResource . StreamSource ( ) {public InputStream getStream ( ) {

St r ing e r r o r = ” e r r o r ” ;

byte [ ] da t i = e r r o r . getBytes ( ) ;

try {dat i = createPDF ( parte1 , agreement , mapping , parte2 ,

graphs , historyE , historyD , context ) ;

ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( ) ;

190 f ina l St r ing pdfCover = ( ( WebApplicationContext ) appl

. getContext ( ) ) . ge tHttpSess ion ( ) . ge tServ l e tContext ( )

. getRealPath ( ”/ pdfs / cover . pdf ” ) ;

f ina l F i l e cover = new F i l e ( pdfCover ) ;

i f ( cover . e x i s t s ( ) ) {List<InputStream> pdfs = new ArrayList<InputStream >() ;

try {pdfs . add (new Fi leInputStream ( cover ) ) ;

} catch ( FileNotFoundException e ) {}

200 pdfs . add (new ByteArrayInputStream ( dat i ) ) ;

PDFmerge . concatPDFs ( pdfs , outputStream , fa l se ) ;

da t i = outputStream . toByteArray ( ) ;

}} catch ( DocumentException e ) {

e . pr intStackTrace ( ) ;

}return new ByteArrayInputStream ( dat i ) ;

}} ;

210 resourcePreviewPDF . setStreamSource ( source ) ;

resourcePreviewPDF . setMIMEType( ” a p p l i c a t i o n / pdf ” ) ;

resourcePreviewPDF . setCacheTime(−1) ;

appl . getMainWindow ( ) . open ( resourcePreviewPDF ) ;

}

190

Page 209: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public StreamResource exportPDFtest ( I n t e g e r qid ) {Document myDoc = documentsMngr . getDocument ( qid ) ;

S t r ing pdfName = myDoc . getFi lename ( ) + ” . pdf ” ;

i f ( resourceDef in i t ivePDF == null )

220 re sourceDef in i t ivePDF = new HashMap<Integer , StreamResource >() ;

StreamResource myPDF;

i f ( resourceDef in i t ivePDF . containsKey ( qid ) ) {myPDF = resourceDef in i t ivePDF . get ( qid ) ;

} else {myPDF = new StreamResource (null , pdfName , appl ) ;

f ina l St r ing pdf = ( ( WebApplicationContext ) appl . getContext ( ) )

. ge tHttpSess ion ( ) . ge tServ l e tContext ( ) . getRealPath (

”/ pdfs /” + pdfName) ;

f ina l St r ing pdfCover = ( ( WebApplicationContext ) appl . getContext ( ) )

230 . ge tHttpSess ion ( ) . ge tServ l e tContext ( ) . getRealPath (

”/ pdfs / cover . pdf ” ) ;

f ina l F i l e f i l e = new F i l e ( pdf ) ;

f ina l F i l e cover = new F i l e ( pdfCover ) ;

System . out . p r i n t l n ( ( cover . e x i s t s ( ) ? ”La cover e s i s t e ”

: ”La cover NON ESISTE” ) ) ;

System . out . p r i n t l n ( ( f i l e . e x i s t s ( ) ? ” I l f i l e e s i s t e ”

: ” I l f i l e NON ESISTE” ) ) ;

try {f ina l List<InputStream> f i l e s = new LinkedList<InputStream >() ;

240 f i l e s . add (new Fi leInputStream ( cover ) ) ;

f i l e s . add (new Fi leInputStream ( f i l e ) ) ;

StreamResource . StreamSource source = new StreamResource . StreamSource ( ) {public InputStream getStream ( ) {

ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( ) ;

PDFmerge . concatPDFs ( f i l e s , outputStream , fa l se ) ;

byte [ ] bytes = outputStream . toByteArray ( ) ;

return new ByteArrayInputStream ( bytes ) ;

}} ;

250 myPDF. setStreamSource ( source ) ;

re sourceDef in i t ivePDF . put ( qid , myPDF) ;

} catch ( FileNotFoundException e1 ) {}

}myPDF. setMIMEType( ” a p p l i c a t i o n / pdf ” ) ;

return myPDF;

}

260 public Agreement ge tPro j e c t ( ) {return r e f e r e n c e P r o j e c t ;

}

public void exportDef in it ivePDF ( St r ing name , f ina l boolean parte1 ,

f ina l boolean agreement , f ina l boolean mapping ,

f ina l boolean parte2 , f ina l boolean graphs , f ina l boolean historyE ,

f ina l boolean historyD , f ina l boolean context ) {St r ing pdfName = name + ” . pdf ” ;

f ina l St r ing pdfs = ( ( WebApplicationContext ) appl . getContext ( ) )

270 . ge tHttpSess ion ( ) . ge tServ l e tContext ( ) . getRealPath (

”/ pdfs /” + pdfName) ;

191

Page 210: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

f ina l F i l e f i l e = new F i l e ( pdfs ) ;

try {f i l e . createNewFi le ( ) ;

} catch ( IOException e2 ) {e2 . pr intStackTrace ( ) ;

}St r ing e r r o r = ” e r r o r ” ;

byte [ ] da t i = e r r o r . getBytes ( ) ;

280 try {dat i = createPDF ( parte1 , agreement , mapping , parte2 , graphs ,

historyE , historyD , context ) ;

OutputStream output = new FileOutputStream ( f i l e ) ;

output . wr i t e ( da t i ) ;

} catch ( DocumentException e ) {e . pr intStackTrace ( ) ;

} catch ( FileNotFoundException e ) {e . pr intStackTrace ( ) ;

} catch ( IOException e ) {290 e . pr intStackTrace ( ) ;

}}

public Command getMenu ( ) {return new Command( ) {

@Override

public void menuSelected ( MenuItem se l e c t ed I t em ) {DocumentCtrl . this . menuSelected ( ) ;

}300 } ;

}

public Document getReferenceDocument ( ) {i f ( referenceDocument != null )

documentsMngr . r e f r e s h ( referenceDocument ) ;

return referenceDocument ;

}

310 public void documentSe lectedHistory ( I n t e g e r qid ) {referenceDocument = documentsMngr . getDocument ( qid ) ;

documenUI . documentDeta i l sHistory ( ) ;

}

public void documentSe lectedDeta i l s ( I n t e g e r qid ) {referenceDocument = documentsMngr . getDocument ( qid ) ;

documenUI . documentDetai ls ( fa l se ) ;

}

320 public enum DocActions {ACCEPT, PROPOSE DELETION, DELETE, REJECT, REJ DELETE;

}

public List<DocActions> getAdmittedActions ( ) {User user = ( ( LoggedUser ) appl . getUser ( ) ) . getUserObj ( ) ;

Role r = UserManager . getRo leForPro jec t ( user , r e f e r e n c e P r o j e c t ) ;

LinkedList<DocActions> r e s = new LinkedList<DocActions >() ;

192

Page 211: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

i f ( r == null )

return r e s ;

330 boolean i s S u p p l i e r = ( r . g e tRo l eDesc r ip t i on ( )

. equa l s IgnoreCase ( RoleTypes .SUPPLIER) ) ;

i f ( referenceDocument . ge tSta tus ( ) . equa l s (

DocumentStatus .PROPOSED CERTIFIER) )

i f ( i s S u p p l i e r ) {r e s . add ( DocActions .ACCEPT) ;

r e s . add ( DocActions .REJECT) ;

} else

r e s . add ( DocActions .REJECT) ;

i f ( referenceDocument . ge tSta tus ( ) . equa l s (

340 DocumentStatus .PROPOSED SUPPLIER) )

i f ( ! i s S u p p l i e r ) {r e s . add ( DocActions .REJECT) ;

r e s . add ( DocActions .ACCEPT) ;

} else

r e s . add ( DocActions .REJECT) ;

i f ( referenceDocument . ge tSta tus ( ) . equa l s (

DocumentStatus .PROPOSED DELETION CERTIFIER)

&& i s S u p p l i e r ) {r e s . add ( DocActions .DELETE) ;

350 r e s . add ( DocActions .REJ DELETE) ;

}i f ( referenceDocument . ge tSta tus ( ) . equa l s (

DocumentStatus .PROPOSED DELETION SUPPLIER)

&& ! i s S u p p l i e r ) {r e s . add ( DocActions .DELETE) ;

r e s . add ( DocActions .REJ DELETE) ;

}i f ( referenceDocument . ge tSta tus ( ) . equa l s ( DocumentStatus .ACCEPTED) )

r e s . add ( DocActions .PROPOSE DELETION) ;

360 return r e s ;

}

public void applyAction ( DocActions act , DocumentHistory dh)

throws SaveException {User user = ( ( LoggedUser ) appl . getUser ( ) ) . getUserObj ( ) ;

Role r = UserManager . getRo leForPro jec t ( user , r e f e r e n c e P r o j e c t ) ;

boolean i s S u p p l i e r = ( r . g e tRo l eDesc r ip t i on ( )

. equa l s IgnoreCase ( RoleTypes .SUPPLIER) ) ;

dh . setDocument ( referenceDocument ) ;

370 dh . setModtime (new Date ( ) ) ;

dh . se tUser ( user ) ;

switch ( act ) {case ACCEPT:

i f ( referenceDocument . ge tSta tus ( ) . equa l s (

DocumentStatus .PROPOSED CERTIFIER)

| | referenceDocument . ge tStatus ( ) . equa l s (

DocumentStatus .PROPOSED SUPPLIER) ) {referenceDocument . s e t S ta tu s ( DocumentStatus .ACCEPTED) ;

i f ( i s S u p p l i e r ) {380 referenceDocument . setModDate (new Date ( ) ) ;

dh . s e tRo le ( ” Supp l i e r ” ) ;

} else {referenceDocument . setModDate (new Date ( ) ) ;

193

Page 212: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

dh . se tRo le ( ” C e r t i f i e r ” ) ;

}dh . se tAct ion ( ” Accepts the proposa l ” ) ;

}break ;

case REJECT:

390 i f ( referenceDocument . ge tSta tus ( ) . equa l s (

DocumentStatus .PROPOSED CERTIFIER)

| | referenceDocument . ge tStatus ( ) . equa l s (

DocumentStatus .PROPOSED SUPPLIER) ) {referenceDocument . s e t S ta tu s ( DocumentStatus .DELETED) ;

i f ( i s S u p p l i e r ) {referenceDocument . setModDate (new Date ( ) ) ;

dh . s e tRo le ( ” Supp l i e r ” ) ;

} else {referenceDocument . setModDate (new Date ( ) ) ;

400 dh . se tRo le ( ” C e r t i f i e r ” ) ;

}dh . se tAct ion ( ” Reject the proposa l ” ) ;

}break ;

case PROPOSE DELETION:

i f ( referenceDocument . ge tSta tus ( ) . equa l s ( DocumentStatus .ACCEPTED) ) {i f ( i s S u p p l i e r ) {

referenceDocument

. s e t S t a t u s ( DocumentStatus .PROPOSED DELETION SUPPLIER) ;

410 referenceDocument . setModDate (new Date ( ) ) ;

dh . s e tRo le ( ” Supp l i e r ” ) ;

} else {referenceDocument

. s e t S t a t u s ( DocumentStatus .PROPOSED DELETION CERTIFIER) ;

referenceDocument . setModDate (new Date ( ) ) ;

dh . s e tRo le ( ” C e r t i f i e r ” ) ;

}dh . se tAct ion ( ” Proposes the d e l e t i o n ” ) ;

}420 break ;

case DELETE:

i f ( referenceDocument . ge tSta tus ( ) . equa l s (

DocumentStatus .PROPOSED DELETION CERTIFIER)

| | referenceDocument . ge tStatus ( ) . equa l s (

DocumentStatus .PROPOSED DELETION SUPPLIER) ) {referenceDocument . s e t S ta tu s ( DocumentStatus .DELETED) ;

i f ( i s S u p p l i e r ) {referenceDocument . setModDate (new Date ( ) ) ;

dh . s e tRo le ( ” Supp l i e r ” ) ;

430 } else {referenceDocument . setModDate (new Date ( ) ) ;

dh . s e tRo le ( ” C e r t i f i e r ” ) ;

}dh . se tAct ion ( ” Accepts the withdrawn” ) ;

}break ;

case REJ DELETE:

i f ( referenceDocument . ge tSta tus ( ) . equa l s (

DocumentStatus .PROPOSED DELETION CERTIFIER)

194

Page 213: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

440 | | referenceDocument . ge tStatus ( ) . equa l s (

DocumentStatus .PROPOSED DELETION SUPPLIER) ) {referenceDocument . s e t S ta tu s ( DocumentStatus .ACCEPTED) ;

i f ( i s S u p p l i e r ) {dh . se tRo le ( ” Supp l i e r ” ) ;

} else {dh . se tRo le ( ” C e r t i f i e r ” ) ;

}dh . se tAct ion ( ” Rejected the withdrawn” ) ;

}450 break ;

}dh . setNewState ( referenceDocument . ge tSta tus ( ) ) ;

documentsMngr . saveDocument ( referenceDocument ) ;

documentsMngr . saveDocumentHist (dh) ;

documentsMngr . r e f r e s h ( r e f e r e n c e P r o j e c t ) ;

documentsMngr . r e f r e s h ( referenceDocument ) ;

documenUI . documentsList ( ) ;

documenUI . documentDetai ls ( fa l se ) ;

}460 }

D.2.6 Classe FilloutValidationCtrl.java

package i t . uniroma2 . norge . c o n t r o l l e r ;

import i t . uniroma2 . norge . common . AnswerStatus ;

import i t . uniroma2 . norge . common . Quest ionStatus ;

import i t . uniroma2 . norge . common . RoleTypes ;

import i t . uniroma2 . norge . model . Del iverablesManager ;

import i t . uniroma2 . norge . model . AgreementManager ;

import i t . uniroma2 . norge . model . QuestionnaireManager ;

import i t . uniroma2 . norge . model . RuleManager ;

10 import i t . uniroma2 . norge . model . UserManager ;

import i t . uniroma2 . norge . model . jpa . Alternat iveAnswer ;

import i t . uniroma2 . norge . model . jpa . AnswerSet ;

import i t . uniroma2 . norge . model . jpa . Evidence ;

import i t . uniroma2 . norge . model . jpa . De l ive rab l eContentHi s to ry ;

import i t . uniroma2 . norge . model . jpa . AnswsetHistory ;

import i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e ;

import i t . uniroma2 . norge . model . jpa . De l ive rab l eEv idence ;

import i t . uniroma2 . norge . model . jpa . Mclass ;

import i t . uniroma2 . norge . model . jpa . Mpackage ;

20 import i t . uniroma2 . norge . model . jpa . Agreement ;

import i t . uniroma2 . norge . model . jpa . Question ;

import i t . uniroma2 . norge . model . jpa . Quest ionna i re ;

import i t . uniroma2 . norge . model . jpa . Role ;

import i t . uniroma2 . norge . model . jpa . RuleExclus ion ;

import i t . uniroma2 . norge . model . jpa . Ru l eMul t ep l i c i ty ;

import i t . uniroma2 . norge . model . jpa . User ;

import i t . uniroma2 . norge . web . EcoreDiagModi f ier ;

import i t . uniroma2 . norge . web . PieChart ;

import i t . uniroma2 . norge . web . F i l l ou tV a l i d a t i o n UI ;

30 import i t . uniroma2 . norge . web . Tes iwebAppl icat ion ;

195

Page 214: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import i t . uniroma2 . norge . web . Val idat ionUI ;

import i t . uniroma2 . norge . web . support . ExclusionBean ;

import i t . uniroma2 . norge . web . support . F i l l i ngBean ;

import i t . uniroma2 . norge . web . support . MenuLinks ;

import java . awt . Color ;

import java . awt . image . BufferedImage ;

import java . i o . ByteArrayInputStream ;

import java . i o . ByteArrayOutputStream ;

40 import java . i o . IOException ;

import java . i o . InputStream ;

import java . i o . S e r i a l i z a b l e ;

import java . u t i l . ArrayList ;

import java . u t i l . Calendar ;

import java . u t i l . C o l l e c t i o n s ;

import java . u t i l . Comparator ;

import java . u t i l . Date ;

import java . u t i l . HashMap ;

import java . u t i l . LinkedHashMap ;

50 import java . u t i l . L inkedLis t ;

import java . u t i l . L i s t ;

import javax . imageio . ImageIO ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . data . Property . ValueChangeListener ;

import com . vaadin . t e rmina l . Resource ;

import com . vaadin . t e rmina l . StreamResource ;

60 import com . vaadin . u i . CheckBox ;

public class F i l l o u t V a l i d a t i o n C t r l implements S e r i a l i z a b l e ,

Property . ValueChangeListener {

private TesiwebAppl icat ion appl ;

protected QuestionnaireManager questionMngr ;

private AgreementManager projectMngr ;

70protected Agreement r e f e r e n c e P r o j e c t ;

private Question r e f e r enceQues t i on ;

private F i l l o u tV a l i da t i o nU I qstUI ;

private RuleManager ruleMngr ;

private RuleExclus ion r e f e r enceRu l eExc lu s i on ;

80 private RuleMul t ep l i c i ty r e f e r e n c e R u l e M u l t e p l i c i t y ;

private AnswerSet re fe renceAnswerSet ;

private Val idat ionUI va l idUI ;

196

Page 215: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private HashMap<Integer , Integer> answerBlockedBy ;

90 private StreamResource resourcePNG1 ;

private StreamResource resourcePNG2 ;

private StreamResource re sourceEcore ;

private StreamResource resourceEcoreDiag ;

private HashMap<Mpackage , StreamResource> resoursePieQPackage ;

100 private HashMap<Mpackage , StreamResource> resoursePieAPackage ;

private HashMap<Mpackage , MpackageRank> packagePr io r i ty ;

private Mpackage re f e rencePackage ;

private HashMap<Integer , AnswerSet> answerSetForProject ;

private Del iverablesManager de l ive rab l e sMngr ;

110 private StreamResource resourcePNG3 ;

private HashMap<Mpackage , StreamResource> resourcePieDPackage ;

public F i l l o u t V a l i d a t i o n C t r l ( f ina l TesiwebAppl icat ion appl ) {projectMngr = new AgreementManager ( ) ;

questionMngr = new QuestionnaireManager ( ) ;

ruleMngr = new RuleManager ( ) ;

120 de l ive rab l e sMngr = new Del iverablesManager ( ) ;

this . appl = appl ;

qstUI = new F i l l ou tV a l i da t i o nU I ( appl ) ;

va l idUI = new Val idat ionUI ( appl ) ;

answerBlockedBy = new HashMap<Integer , Integer >() ;

resoursePieQPackage = new HashMap<Mpackage , StreamResource >() ;

resoursePieAPackage = new HashMap<Mpackage , StreamResource >() ;

resourcePieDPackage = new HashMap<Mpackage , StreamResource >() ;

packagePr io r i ty = new HashMap<Mpackage , MpackageRank>() ;

answerSetForProject = new HashMap<Integer , AnswerSet >() ;

130 }

public List<Question> getLis tData ( ) {Quest ionna i re q = r e f e r e n c e P r o j e c t . ge tQues t i onna i r e ( ) ;

questionMngr . r e f r e s h ( q ) ;

return q . getQuest ions ( ) ;

}

public List<Question> getLis tData ( Mpackage pkg ) {i f ( pkg == null )

140 return null ;

L i s t<Question> r e s = questionMngr . v iewAl lQuest ions ( pkg ) ;

i f ( r e s == null )

197

Page 216: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

r e s = new ArrayList<Question >() ;

return r e s ;

}

public List<MpackageRank> getListDataMpackage ( ) {List<MpackageRank> r e s = new ArrayList<MpackageRank>( packagePr io r i ty

. va lue s ( ) ) ;

150 C o l l e c t i o n s . s o r t ( res , new Comparator<MpackageRank>() {@Override

public int compare ( MpackageRank o1 , MpackageRank o2 ) {i f ( o1 . g e t P r i o r i t y ( ) > o2 . g e t P r i o r i t y ( ) )

return −1;

i f ( o1 . g e t P r i o r i t y ( ) < o2 . g e t P r i o r i t y ( ) )

return 1 ;

return 0 ;

}}) ;

160 int i = 1 ;

for ( MpackageRank p : r e s ) {p . setRank ( i ) ;

i ++;

}C o l l e c t i o n s . s o r t ( res , new Comparator<MpackageRank>() {

@Override

public int compare ( MpackageRank o1 , MpackageRank o2 ) {return o1 . getMpackage ( ) . compareTo ( o2 . getMpackage ( ) ) ;

}170 }) ;

return r e s ;

}

public List<AnswerSet> getListDataAnswer ( ) {List<AnswerSet> a s l i s t = questionMngr . viewAllAnswerSets (

r e f e r e n c e P r o j e c t , r e f e r encePackage ) ;

C o l l e c t i o n s . s o r t ( a s l i s t , new Comparator<AnswerSet >() {@Override

public int compare ( AnswerSet o1 , AnswerSet o2 ) {180 System . out . p r i n t l n ( o1 . getApprovat ionStatusFina l ( ) ) ;

i f ( o1 . getApprovat ionStatusFina l ( ) . equa l s IgnoreCase (

Quest ionStatus .ACCEPTED) )

return 1 ;

else i f ( o2 . getApprovat ionStatusFina l ( ) . equa l s IgnoreCase (

Quest ionStatus .ACCEPTED) )

return −1;

else i f ( o1 . g e t P r i o r i t y ( ) > o2 . g e t P r i o r i t y ( ) )

return −1;

else i f ( o1 . g e t P r i o r i t y ( ) < o2 . g e t P r i o r i t y ( ) )

190 return 1 ;

return 0 ;

}}) ;

int i = 1 ;

for ( AnswerSet a : a s l i s t ) {a . setRanking ( i ) ;

i ++;

}

198

Page 217: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return a s l i s t ;

200 }

public void c r e a t e ( Quest ionna i re q ) throws SaveException {questionMngr . saveQuest ionna i r e ( q ) ;

}

public void menuSelected ( Agreement masterPro ject ) {User user = ( ( LoggedUser ) appl . getUser ( ) ) . getUserObj ( ) ;

Role r = UserManager . getRo leForPro jec t ( user , masterPro ject ) ;

i f ( r != null ) {210 i f ( r . getCode ( ) . equa l s ( ” s u p p l i e r ” ) )

menuSelected ( MenuLinks . FILLING) ;

else i f ( r . getCode ( ) . equa l s ( ” c e r t i f i e r ” ) )

menuSelected ( MenuLinks .VALIDATION) ;

else

appl . showNot i f i c a t i on ( ” Exception : no r o l e s f o r t h i s p r o j e c t ( ”

+ masterPro ject . getName ( ) + ” ) ” , true ) ;

}}

220 public void menuSelected ( St r ing s e l e c t ed I t em ) {St r ing item = se l e c t ed I t em ;

appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

appl . showNot i f i c a t i on ( item ) ;

LoggedUser user = ( LoggedUser ) appl . getUser ( ) ;

i f ( item . equa l s ( MenuLinks . FILLING) ) {qstUI . p r o j e c t s L i s t ( ) ;

L i s t<Agreement> tmp = user . p ro j e c t sForRo l e ( ” s u p p l i e r ” ) ;

i f (tmp . s i z e ( ) == 1 | | appl . getMasterPro ject ( ) != null ) {Agreement p r j ;

230 i f ( appl . getMasterPro ject ( ) != null )

p r j = appl . getMasterPro jec t ( ) ;

else

pr j = tmp . get (0 ) ;

qstUI . p r o j e c t L i s t . s e l e c t ( p r j ) ;

appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

r e f e r e n c e P r o j e c t = pr j ;

i n i t P r o j e c t I n f o r m a t i o n ( ) ;

i f ( ! checkSi lAnswered ( ) )

q u e s t i o n S i l D e t a i l s ( ) ;

240 qstUI . packagesL i s t ( ) ;

}} else {

va l idUI . p r o j e c t s L i s t ( ) ;

L i s t<Agreement> tmp = user . p ro j e c t sForRo l e ( ” c e r t i f i e r ” ) ;

i f (tmp . s i z e ( ) == 1 | | appl . getMasterPro ject ( ) != null ) {Agreement p r j ;

i f ( appl . getMasterPro ject ( ) != null )

p r j = appl . getMasterPro jec t ( ) ;

else

250 pr j = tmp . get (0 ) ;

va l idUI . p r o j e c t L i s t . s e l e c t ( p r j ) ;

appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

r e f e r e n c e P r o j e c t = pr j ;

i n i t P r o j e c t I n f o r m a t i o n ( ) ;

199

Page 218: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

va l idUI . packagesL i s t ( ) ;

}}

}

260 private boolean checkSi lAnswered ( ) {i f ( i s S i l Q u e s t i o n n a i r e ( ) ) {

I n t e g e r qid = r e f e r e n c e P r o j e c t . ge tQues t i onna i r e ( ) . g e tS i lQue s t i on ( )

. getQuest ionId ( ) ;

AnswerSet aaa = questionMngr . getAnswerSet ( qid ) ;

i f ( aaa == null ) {System . out

. p r i n t l n ( ”domanda SIL non r i s p o s t a ( AnswerSet non trovato per qid ”

+ qid + ” ) ” ) ;

return fa l se ;

270 } else {for ( Evidence a : aaa . getAnswsetAnsws ( ) ) {

i f ( a . getResponse ( ) != null

&& a . getResponse ( ) . equa l s IgnoreCase ( ” yes ” ) ) {System . out . p r i n t l n ( ”domanda SIL r i s p o s t a ( ” + qid

+ ” ) −> l i v e l l o = ”

+ a . getAlternat iveAnswer ( ) . getAnswer ( ) ) ;

return true ;

}}

280 System . out

. p r i n t l n ( ”domanda SIL non r i s p o s t a ( AnswerSet t rovato per ”

+ qid + ” ma nessun s i ) ” ) ;

return fa l se ;

}}return true ;

}

protected void i n i t P r o j e c t I n f o r m a t i o n ( ) {290 System . out . p r i n t l n ( Calendar . g e t In s tance ( ) . ge tT imeInMi l l i s ( )

+ ” i n i z i o i n i t P r o j e c t I n f o r m a t i o n ( ) ” ) ;

HashMap<Integer , AnswerSet> as s = new HashMap<Integer , AnswerSet >() ;

for ( AnswerSet as : questionMngr . viewAllAnswerSets ( r e f e r e n c e P r o j e c t ) )

a s s . put ( as . getQuest ion ( ) . getQuest ionId ( ) , as ) ;

for ( Question q : r e f e r e n c e P r o j e c t . ge tQues t i onna i r e ( ) . getQuest ions ( ) ) {AnswerSet as = null ;

i f ( ! a s s . containsKey ( q . getQuest ionId ( ) ) ) {as = new AnswerSet ( ) ;

as . s e tQuest ion ( q ) ;

300 as . s e t P r o j e c t ( r e f e r e n c e P r o j e c t ) ;

as . s e tApprovat ionStatusF ina l ( Quest ionStatus .TO SPECIFY) ;

try {as = questionMngr . saveAnswerSet ( as ) ;

} catch ( SaveException e1 ) {e1 . pr intStackTrace ( ) ;

}as = questionMngr . getAnswerSet ( q . getQuest ionId ( ) ) ;

} else {as = ass . get ( q . getQuest ionId ( ) ) ;

310 }

200

Page 219: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

i f ( as . getAnswsetAnsws ( ) == null

| | as . getAnswsetAnsws ( ) . s i z e ( ) == 0) {HashMap<Integer , Evidence> be f o r e = new HashMap<Integer , Evidence >() ;

i f ( as . getAnswsetAnsws ( ) != null )

for ( Evidence a : as . getAnswsetAnsws ( ) )

i f ( a . getAlternat iveAnswer ( ) . g e tFathe rA l t e rna t ive ( ) == null ) {be f o r e . put ( a . getAlternat iveAnswer ( ) . getAnswerId ( ) ,

a ) ;

}320 for ( Alternat iveAnswer x : q . getAlternat iveAnswers ( ) )

i f ( x . g e tFathe rA l t e rna t ive ( ) == null ) {Evidence asa ;

i f ( ! b e f o r e . containsKey ( x . getAnswerId ( ) ) ) {Evidence y = new Evidence ( ) ;

y . setAnswsetAnswId (0 ) ;

y . se tAl ternat iveAnswer ( x ) ;

y . setAnswerSet ( as ) ;

y . setApprovat ionStatus ( ”” ) ;

y . s e tApprovat ionDe l ivStatus ( ”” ) ;

330 y . setResponse ( ”” ) ;

try {y = questionMngr . saveAnswsetAnsw ( y ) ;

} catch ( SaveException e ) {e . pr intStackTrace ( ) ;

}asa = y ;

} else

asa = be fo r e . get ( x . getAnswerId ( ) ) ;

questionMngr . r e f r e s h ( asa ) ;

340 HashMap<Integer , Evidence> be fo r e1 = new HashMap<Integer , Evidence >() ;

for ( Evidence a : asa . getSonAnswsetAnsws ( ) )

i f ( a . getAlternat iveAnswer ( ) . g e tFathe rA l t e rna t ive ( ) != null )

be fo r e1 . put ( a . getAlternat iveAnswer ( )

. getAnswerId ( ) , a ) ;

questionMngr . r e f r e s h ( x ) ;

for ( Alternat iveAnswer x1 : x . g e tSonAl t e rnat ive s ( ) ) {i f ( ! be f o r e1 . containsKey ( x1 . getAnswerId ( ) ) ) {

Evidence y1 = new Evidence ( ) ;

y1 . setFatherAnswsetAnsws ( asa ) ;

350 y1 . setAnswsetAnswId (0 ) ;

y1 . se tAl ternat iveAnswer ( x1 ) ;

y1 . setAnswerSet ( as ) ;

y1 . setApprovat ionStatus ( ”” ) ;

y1 . se tApprovat ionDe l ivStatus ( ”” ) ;

y1 . setResponse ( ”” ) ;

try {y1 = questionMngr . saveAnswsetAnsw ( y1 ) ;

} catch ( SaveException e ) {e . pr intStackTrace ( ) ;

360 }} else {}

}}

questionMngr . r e f r e s h ( as ) ;

}

201

Page 220: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

System . out . p r i n t l n ( ” ” + as . getAnswerSetId ( ) + ” −> ” + as ) ;

answerSetForProject . put ( as . getAnswerSetId ( ) , as ) ;

}370 System . out . p r i n t l n ( Calendar . g e t In s tance ( ) . ge tT imeInMi l l i s ( )

+ ” new as i n i t P r o j e c t I n f o r m a t i o n ( ) ” ) ;

L i s t<Mpackage> pkgs = questionMngr

. getPackagesForQuest ionnaire ( r e f e r e n c e P r o j e c t

. ge tQues t i onna i r e ( ) ) ;

System . out . p r i n t l n ( Calendar . g e t In s tance ( ) . ge tT imeInMi l l i s ( )

+ ” getPackagesForQuest ionnaire i n i t P r o j e c t I n f o r m a t i o n ( ) ” ) ;

for ( Mpackage p : pkgs )

g e t P r i o r i t y (p) ;

System . out . p r i n t l n ( Calendar . g e t In s tance ( ) . ge tT imeInMi l l i s ( )

380 + ” f i n e i n i t P r o j e c t I n f o r m a t i o n ( ) ” ) ;

}

@Override

public void valueChange ( ValueChangeEvent event ) {appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

r e f e r e n c e P r o j e c t = ( Agreement ) qstUI . p r o j e c t L i s t . getValue ( ) ;

i n i t P r o j e c t I n f o r m a t i o n ( ) ;

i f ( ! checkSi lAnswered ( ) )

q u e s t i o n S i l D e t a i l s ( ) ;

390 qstUI . packagesL i s t ( ) ;

}

public void viewAl l ( Agreement p r j ) {r e f e r e n c e P r o j e c t = pr j ;

qstUI . q u e s t i o n s L i s t ( ) ;

}

public void c r e a t e ( Question quest ) throws SaveException {400 quest . s e tQue s t i onna i r e ( r e f e r e n c e P r o j e c t . ge tQues t i onna i r e ( ) ) ;

questionMngr . saveQuest ion ( quest ) ;

i f ( r e f e r e n c e P r o j e c t . ge tQues t i onna i r e ( ) . getQuest ions ( ) == null ) {ArrayList<Question> que s t i on s = new ArrayList<Question >() ;

r e f e r e n c e P r o j e c t . ge tQues t i onna i r e ( ) . s e tQues t i ons ( que s t i on s ) ;

}List<Question> que s t i on s = r e f e r e n c e P r o j e c t . ge tQues t i onna i r e ( )

. getQuest ions ( ) ;

que s t i on s . add ( quest ) ;

projectMngr . savePro j e c t ( r e f e r e n c e P r o j e c t ) ;

410 qstUI . q u e s t i o n s L i s t ( ) ;

}

public List<AlternativeAnswer> getAnswerListData ( ) {questionMngr . r e f r e s h ( re fe renceAnswerSet ) ;

return re f e renceAnswerSet . getQuest ion ( ) . getAlternat iveAnswers ( ) ;

}

public void packageSe lec ted ( Mpackage mpackage ) {420 r e f e r encePackage = mpackage ;

qstUI . q u e s t i o n s L i s t ( ) ;

}

202

Page 221: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void packageSe l e c t edVa l ida t i on ( Mpackage mpackage ) {r e f e r encePackage = mpackage ;

va l idUI . q u e s t i o n s L i s t ( ) ;

}

430private class Pr jVa l i dSe l e c t ed implements Property . ValueChangeListener {

@Override

public void valueChange ( ValueChangeEvent event ) {r e f e r e n c e P r o j e c t = ( Agreement ) va l idUI . p r o j e c t L i s t . getValue ( ) ;

i n i t P r o j e c t I n f o r m a t i o n ( ) ;

va l idUI . packagesL i s t ( ) ;

}}

440

public void q u e s t i o n S e l e c t e d H i s t o r y ( I n t e g e r qid ) {re f e renceAnswerSet = answerSetForProject . get ( qid ) ;

qstUI . q u e s t i o n D e t a i l s H i s t o r y ( ) ;

}

public void q u e s t i o n S e l e c t e d D e t a i l s ( I n t e g e r qid ) {i f ( checkSi lAnswered ( ) ) {

450 re f e renceAnswerSet = answerSetForProject . get ( qid ) ;

i f ( re fe renceAnswerSet != null ) {r e f e r enceQues t i on = re ferenceAnswerSet . getQuest ion ( ) ;

qstUI . q u e s t i o n D e t a i l s ( fa l se ) ;

} else {System . out

. p r i n t l n ( ” answerSetForProject non cont i ene ” + qid ) ;

}}

}460

public void ques t i onSe l e c t edEv idence ( I n t e g e r qid ) {re f e renceAnswerSet = answerSetForProject . get ( qid ) ;

qstUI . que s t i onDeta i l sEv idence ( false , null ) ;

}

public void ques t ionVa l idat ionEv idence ( I n t e g e r qid ) {re f e renceAnswerSet = answerSetForProject . get ( qid ) ;

va l idUI . que s t i onDeta i l sEv idence ( false , null ) ;

}470

public List<Del ive rab l e> g e t D e l i v e r a b l e s L i s t ( ) {de l ive rab l e sMngr . r e f r e s h ( r e f e r e n c e P r o j e c t ) ;

return r e f e r e n c e P r o j e c t . g e t D e l i v e r a b l e s ( ) ;

}

public void que s t i onVa l i da t i onH i s t o ry ( I n t e g e r qid ) {re f e renceAnswerSet = answerSetForProject . get ( qid ) ;

203

Page 222: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

va l idUI . q u e s t i o n D e t a i l s H i s t o r y ( ) ;

480 }

public void ques t i onVa l ida t i onEv idenceHi s to ry ( I n t e g e r qid ) {re f e renceAnswerSet = answerSetForProject . get ( qid ) ;

va l idUI . q u e s t i o n D e t a i l s H i s t o r y ( ) ;

}

public void q u e s t i o n V a l i d a t i o n D e t a i l s ( I n t e g e r qid ) {re f e renceAnswerSet = answerSetForProject . get ( qid ) ;

va l idUI . q u e s t i o n D e t a i l s ( fa l se ) ;

490 }

public AnswerSet getAnswerSetIsPresent ( I n t e g e r qid ) {AnswerSet as = questionMngr . getAnswerSet ( qid ) ;

return as ;

}

public void checkRulesDynamic (HashMap<Integer , F i l l ingBean> f i l l i n g s ,

500 I n t e g e r a id ) {System . out . p r i n t l n ( ”\n\n\n I n i z i o check ing dinamico per ” + aid ) ;

Alternat iveAnswer aa = null ;

F i l l i ngBean f i l l = null ;

CheckBox cb ;

i f ( f i l l i n g s . containsKey ( a id ) ) {f i l l = f i l l i n g s . get ( a id ) ;

aa = f i l l . getAnswsetAnsw ( ) . getAlternat iveAnswer ( ) ;

cb = f i l l . getYesno ( ) ;

Boolean checked = ( Boolean ) cb . getValue ( ) ;

510 i f ( checked == null )

checked = fa l se ;

Question qT = re ferenceAnswerSet . getQuest ion ( ) ;

Alternat iveAnswer aT = aa ;

Li s t<RuleExclusion> rEL = aT . getRuleExc lus ionsTarget ( ) ;

for ( RuleExclus ion re : rEL) {Alternat iveAnswer aS = re . getAlternat iveAnswerSource ( ) ;

System . out . p r i n t l n ( ” A n a l i s i r e g o l a : aT=” + aT . getAnswerId ( )

+ ” / aS=” + aS . getAnswerId ( ) ) ;

520 Question qS = aS . getQuest ion ( ) ;

i f (qT . getQuest ionId ( ) == qS . getQuest ionId ( ) ) {i f ( checked ) {

answerBlockedBy . put ( aS . getAnswerId ( ) , answerBlockedBy

. get ( aS . getAnswerId ( ) ) + 1) ;

} else {i f ( ! answerBlockedBy . containsKey ( aS . getAnswerId ( ) ) )

System . out

. p r i n t l n ( ”Non c ’ e i l contato re d e l l e b l o c ca t e per ”

+ aS . getAnswerId ( ) ) ;

530 answerBlockedBy . put ( aS . getAnswerId ( ) , answerBlockedBy

. get ( aS . getAnswerId ( ) ) − 1) ;

}System . out . p r i n t l n ( ” ?? La r i s p o s t a ” + aS . getAnswerId ( )

+ ” adesso e b l o cca ta da ”

204

Page 223: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

+ answerBlockedBy . get ( aS . getAnswerId ( ) )

+ ” r e g o l e [ t a r g e t ] ” ) ;

}}rEL = aT . getRuleExc lus ionsSource ( ) ;

540 for ( RuleExclus ion re : rEL) {Alternat iveAnswer aS = re . getAlternat iveAnswerTarget ( ) ;

System . out . p r i n t l n ( ” A n a l i s i r e g o l a : aT=” + aT . getAnswerId ( )

+ ” / aS=” + aS . getAnswerId ( ) ) ;

Question qS = aS . getQuest ion ( ) ;

i f (qT . getQuest ionId ( ) == qS . getQuest ionId ( ) ) {i f ( checked )

answerBlockedBy . put ( aS . getAnswerId ( ) , answerBlockedBy

. get ( aS . getAnswerId ( ) ) + 1) ;

else

550 answerBlockedBy . put ( aS . getAnswerId ( ) , answerBlockedBy

. get ( aS . getAnswerId ( ) ) − 1) ;

}System . out . p r i n t l n ( ” ?? La r i s p o s t a ” + aS . getAnswerId ( )

+ ” adesso e b l o cca ta da ”

+ answerBlockedBy . get ( aS . getAnswerId ( ) )

+ ” r e g o l e [ source ] ” ) ;

}}for ( I n t e g e r k : answerBlockedBy . keySet ( ) )

560 i f ( k != aid && f i l l i n g s . containsKey ( k ) ) {System . out . p r i n t l n ( ”La r i s p o s t a ” + k

+ ” adesso e b l o cca ta da ” + answerBlockedBy . get ( k )

+ ” r e g o l e ” ) ;

boolean tmp ;

i f ( answerBlockedBy . get ( k ) > 0)

tmp = fa l se ;

else {tmp = true ;

}570 f i l l i n g s . get ( k ) . getYesno ( ) . setEnabled (tmp) ;

f i l l i n g s . get ( k ) . enab leChi ldren ( ) ;

}}

public boolean checkRu le sSta t i c ( F i l l i ngBean f ) {i f ( ! answerBlockedBy . containsKey ( f ) )

answerBlockedBy . put ( f . getAnswerId ( ) , 0) ;

i f ( f . getAnswsetAnsw ( ) . getResponse ( ) . equa l s ( ” yes ” ) )

return true ;

580 Question qT = re ferenceAnswerSet . getQuest ion ( ) ;

Alternat iveAnswer aT = f . getAnswsetAnsw ( ) . getAlternat iveAnswer ( ) ;

{

{List<RuleExclusion> rEL = aT . getRuleExc lus ionsTarget ( ) ;

for ( RuleExclus ion re : rEL) {Alternat iveAnswer aS = re . getAlternat iveAnswerSource ( ) ;

Question qS = aS . getQuest ion ( ) ;

i f (qT . getQuest ionId ( ) != qS . getQuest ionId ( ) ) {590 AnswerSet x = questionMngr . getAnswerSet ( qS

205

Page 224: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

. getQuest ionId ( ) ) ;

for ( Evidence y : x . getAnswsetAnsws ( ) ) {Alternat iveAnswer a = y . getAlternat iveAnswer ( ) ;

i f ( a . getAnswerId ( ) == aS . getAnswerId ( )

&& y . getResponse ( ) . equa l s ( ” yes ” ) ) {answerBlockedBy

. put ( f . getAnswerId ( ) , answerBlockedBy

. get ( f . getAnswerId ( ) ) + 1) ;

}600 }

} else {for ( Evidence y : re fe renceAnswerSet

. getAnswsetAnsws ( ) ) {Alternat iveAnswer a = y . getAlternat iveAnswer ( ) ;

i f ( a . getAnswerId ( ) == aS . getAnswerId ( )

&& y . getResponse ( ) . equa l s ( ” yes ” ) ) {answerBlockedBy

. put ( f . getAnswerId ( ) , answerBlockedBy

. get ( f . getAnswerId ( ) ) + 1) ;

610 }}

}}rEL = aT . getRuleExc lus ionsSource ( ) ;

for ( RuleExclus ion re : rEL) {Alternat iveAnswer aS = re . getAlternat iveAnswerTarget ( ) ;

Question qS = aS . getQuest ion ( ) ;

i f (qT . getQuest ionId ( ) != qS . getQuest ionId ( ) ) {AnswerSet x = questionMngr . getAnswerSet ( qS

620 . getQuest ionId ( ) ) ;

i f ( x != null && x . getAnswsetAnsws ( ) != null )

for ( Evidence y : x . getAnswsetAnsws ( ) ) {Alternat iveAnswer a = y . getAlternat iveAnswer ( ) ;

i f ( a . getAnswerId ( ) == aS . getAnswerId ( )

&& y . getResponse ( ) . equa l s ( ” yes ” ) ) {answerBlockedBy . put ( f . getAnswerId ( ) ,

answerBlockedBy

. get ( f . getAnswerId ( ) ) + 1) ;

}630 }

} else {for ( Evidence y : re fe renceAnswerSet

. getAnswsetAnsws ( ) ) {Alternat iveAnswer a = y . getAlternat iveAnswer ( ) ;

i f ( a . getAnswerId ( ) == aS . getAnswerId ( )

&& y . getResponse ( ) . equa l s ( ” yes ” ) ) {answerBlockedBy

. put ( f . getAnswerId ( ) , answerBlockedBy

. get ( f . getAnswerId ( ) ) + 1) ;

640 }}

}}

}}i f ( answerBlockedBy . get ( f . getAnswerId ( ) ) > 0)

206

Page 225: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return fa l se ;

return true ;

}650

public void saveAnswerSet ( ArrayList<Evidence> response ,

AnswerSet response2 , AnswsetHistory h i s t ) {LoggedUser l u s e r = ( LoggedUser ) appl . getUser ( ) ;

User user = l u s e r . getUserObj ( ) ;

S t r ing h i s tAct i on = ”” ;

for ( Evidence a : re sponse ) {a . s e t F i l l U s e r ( user ) ;

a . s e tF i l lLas tmod (new Date ( ) ) ;

try {660 questionMngr . saveAnswsetAnsw ( a ) ;

} catch ( SaveException e ) {e . pr intStackTrace ( ) ;

}i f ( a . getResponse ( ) . equa l s IgnoreCase ( ” yes ” ) )

h i s tAct i on += a . getAlternat iveAnswer ( ) . getAnswer ( ) + ”\n” ;

}questionMngr . r e f r e s h ( re fe renceAnswerSet ) ;

try {i f ( re sponse2 . getApprovat ionStatusFina l ( ) == null

670 | | re sponse2 . getApprovat ionStatusFina l ( ) . equa l s (

Quest ionStatus .TO SPECIFY) )

response2

. se tApprovat ionStatusF ina l ( Quest ionStatus .YET TO ANALYZE) ;

re sponse2 . s e tF i l lLas tmod (new Date ( ) ) ;

questionMngr . saveAnswerSet ( response2 ) ;

} catch ( SaveException e ) {e . pr intStackTrace ( ) ;

}i f ( h i s tAct i on . l ength ( ) == 0)

680 h i s tAct i on = ”No a l t e r n a t i v e has not been s e l e c t e d ” ;

else

h i s tAct i on = ”The user has s e l e c t e d the f o l l o w i n g a l t e r n a t i v e s :\n”

+ h i s tAct i on ;

h i s t . setAnswerSet ( response2 ) ;

h i s t . setModtime (new Date ( ) ) ;

h i s t . s e tUser ( user ) ;

h i s t . s e tAct ion ( h i s tAct i on ) ;

try {questionMngr . saveAnswsetHist ( h i s t ) ;

690 } catch ( SaveException e ) {e . pr intStackTrace ( ) ;

}questionMngr . r e f r e s h ( r e f e r enceQues t i on ) ;

questionMngr . r e f r e s h ( re fe renceAnswerSet ) ;

appl . showNot i f i c a t i on ( ”Changes have been saved ” ) ;

qstUI . q u e s t i o n D e t a i l s ( fa l se ) ;

qstUI . q u e s t i o n s L i s t ( ) ;

}

700 public Pr jVa l i dSe l e c t ed g e t P r o j e c t V a l i d a t i o n S e l e c t e d ( ) {return new Pr jVa l i dSe l e c t ed ( ) ;

}

207

Page 226: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void saveApprovation ( ArrayList<Evidence> response ,

AnswerSet response2 , AnswsetHistory h i s t ) {System . out . p r i n t l n ( ” Sa lva tagg io approvazione ” ) ;

LoggedUser l u s e r = ( LoggedUser ) appl . getUser ( ) ;

User user = l u s e r . getUserObj ( ) ;

S t r ing s t a t e = Quest ionStatus .YET TO ANALYZE;

710 St r ing h i s tAct i on = ”” ;

for ( Evidence x : re sponse ) {x . setApprovUser ( user ) ;

x . setApprovLastmod (new Date ( ) ) ;

i f ( x . getApprovat ionStatus ( ) != null ) {i f ( x . getApprovat ionStatus ( ) . equa l s ( AnswerStatus .PROPOSED) )

s t a t e = AnswerStatus .PROPOSED;

else i f ( s t a t e != AnswerStatus .PROPOSED)

s t a t e = AnswerStatus .ACCEPTED;

} else {720 s t a t e = AnswerStatus .PROPOSED;

}try {

questionMngr . saveAnswsetAnsw ( x ) ;

} catch ( SaveException e ) {appl . showNot i f i c a t i on ( ” Error sav ing ’ ”

+ x . getAlternat iveAnswer ( ) . getAnswer ( ) + ” ’ ” ) ;

}i f ( x . getApprovat ionStatus ( ) != null

&& ! x . getApprovat ionStatus ( ) . equa l s IgnoreCase ( ”” ) )

730 h i s tAct i on += x . getAlternat iveAnswer ( ) . getAnswer ( ) + ” : ”

+ x . getApprovat ionStatus ( ) + ”\n” ;

}questionMngr . r e f r e s h ( re fe renceAnswerSet ) ;

i f ( s t a t e != AnswerStatus .PROPOSED && response2 . getQuest ion ( ) != null

&& response2 . getQuest ion ( ) . getOpenQuestion ( ) != null

&& response2 . getQuest ion ( ) . getOpenQuestion ( ) . equa l s ( ” yes ” ) ) {s t a t e = AnswerStatus .ACCEPTED;

}s t a t e = AnswerStatus .REJECTED;

740 re sponse2 . se tApprovat ionStatusF ina l ( s t a t e ) ;

r e sponse2 . setApprovLastmod (new Date ( ) ) ;

try {questionMngr . saveAnswerSet ( response2 ) ;

} catch ( SaveException e ) {e . pr intStackTrace ( ) ;

}i f ( response2 . getQuest ion ( ) . getOpenQuestion ( ) != null

&& response2 . getQuest ion ( ) . getOpenQuestion ( ) . equa l s IgnoreCase (

” yes ” ) && response2 . getApprovat ionStatus ( ) != null

750 && ! response2 . getApprovat ionStatus ( ) . equa l s IgnoreCase ( ”” ) )

h i s tAct i on += ”Open answer : ” + response2 . getApprovat ionStatus ( )

+ ”\n” ;

i f ( h i s tAct i on . l ength ( ) == 0)

h i s tAct i on = ”No v a l i d a t i o n ” ;

h i s t . setAnswerSet ( response2 ) ;

h i s t . setModtime (new Date ( ) ) ;

h i s t . s e tUser ( user ) ;

h i s t . s e tAct ion ( h i s tAct i on ) ;

208

Page 227: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

try {760 questionMngr . saveAnswsetHist ( h i s t ) ;

} catch ( SaveException e ) {e . pr intStackTrace ( ) ;

}questionMngr . r e f r e s h ( re fe renceAnswerSet ) ;

appl . showNot i f i c a t i on ( ”Changes have been saved ” ) ;

va l idUI . showConfirmationQuestion ( ) ;

}

public enum f ina lApprovStatus {770 AGREED, PART AGREED, DISAGREED

} ;

public void saveFinalApprovat ion ( f ina lApprovStatus agreed ) {AnswerSet re sponse = re ferenceAnswerSet ;

i f ( re sponse . getApprovat ionStatusFina l ( ) != null ) {switch ( agreed ) {case AGREED:

response . s e tApprovat ionStatusFina l ( Quest ionStatus .ACCEPTED) ;

break ;

780 case DISAGREED:

response . s e tApprovat ionStatusFina l ( Quest ionStatus .REJECTED) ;

break ;

case PART AGREED:

response . s e tApprovat ionStatusFina l ( Quest ionStatus .PART AGREED) ;

break ;

}}re sponse . setApprovLastmod (new Date ( ) ) ;

790 try {questionMngr . saveAnswerSet ( re sponse ) ;

} catch ( SaveException e ) {e . pr intStackTrace ( ) ;

}va l idUI . q u e s t i o n s L i s t ( ) ;

}

public void showRulesMultep l i c i ty (HashMap<Integer , F i l l ingBean> f i l l i n g s ,

int aid2 ) {800 int ansNum = 0 ;

for ( I n t e g e r a id : f i l l i n g s . keySet ( ) ) {Boolean yn = ( Boolean ) f i l l i n g s . get ( a id ) . getYesno ( ) . getValue ( ) ;

i f ( yn == true ) {ansNum++;

}}St r ing tmp , k ;

int lb , ub ;

LinkedList<Str ing> keys = new LinkedList<Str ing >() ;

810 keys . add ( ”ok” ) ;

keys . add ( ” e r r o r ” ) ;

HashMap<Str ing , L i s t<Str ing>> r i s = new HashMap<Str ing , L i s t<Str ing >>() ;

r i s . put ( ”ok” , new ArrayList<Str ing >() ) ;

r i s . put ( ” e r r o r ” , new ArrayList<Str ing >() ) ;

209

Page 228: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

List<RuleMul tep l i c i ty> r u l e s = re f e r enceQues t i on

. g e t R u l e M u l t e p l i c i t i e s ( ) ;

Alternat iveAnswer altR ;

for ( Ru l eMul t ep l i c i ty r : r u l e s ) {altR = r . getAlternat iveAnswer ( ) ;

820 Question qstR = altR . getQuest ion ( ) ;

Evidence response = questionMngr . getAnswsetAnsw (

re fe renceAnswerSet . g e tPro j e c t ( ) , altR ) ;

i f ( re sponse != null && response . getResponse ( ) != null

&& response . getResponse ( ) . toLowerCase ( ) . equa l s ( ” yes ” ) ) {lb = ub = 0 ;

tmp = ” requ i r ed ” + lb + ” . . ” + ub + ” : ques t i on ”

+ qstR . getQuest ion ( ) + ” , answer ” + altR . getAnswer ( ) ;

k = ” e r r o r ” ;

i f (ansNum >= lb && ansNum <= ub)

830 k = ”ok” ;

r i s . get ( k ) . add (tmp) ;

}}qstUI . showMultRules ( r i s , keys ) ;

}

public void showRules (HashMap<Integer , F i l l ingBean> f i l l i n g s , I n t e g e r a id ) {HashMap<Str ing , L i s t<ExclusionBean>> tmp2 = showRulesTo ( f i l l i n g s , a id ) ;

HashMap<Str ing , L i s t<ExclusionBean>> r i s = new HashMap<Str ing ,

L i s t<ExclusionBean >>() ;

840 LinkedList<Str ing> l = new LinkedList<Str ing >() ;

l . add ( ” excluded2 ” ) ;

LinkedList<ExclusionBean> r i sV = new LinkedList<ExclusionBean >() ;

for ( S t r ing k : tmp2 . keySet ( ) ) {r i sV . addAll ( tmp2 . get ( k ) ) ;

}C o l l e c t i o n s . s o r t ( r i sV ) ;

r i s . put ( ” excluded2 ” , r i sV ) ;

qstUI . showExclRules ( r i s , l ) ;

}850

public HashMap<Str ing , L i s t<ExclusionBean>> showRulesTo (

HashMap<Integer , F i l l ingBean> f i l l i n g s , I n t e g e r a id ) {ExclusionBean tmp ;

LinkedList<Str ing> keys = new LinkedList<Str ing >() ;

HashMap<Str ing , L i s t<ExclusionBean>> r i s = new HashMap<Str ing ,

L i s t<ExclusionBean >>() ;

LinkedList<ExclusionBean> exded = new LinkedList<ExclusionBean >() ;

LinkedList<ExclusionBean> may exded = new LinkedList<ExclusionBean >() ;

L i s t<AlternativeAnswer> ans = re ferenceAnswerSet . getQuest ion ( )

. getAlternat iveAnswers ( ) ;

860 for ( Alternat iveAnswer a : ans )

i f ( a . getAnswerId ( ) == aid ) {List<RuleExclusion> r s = a . getRuleExc lus ionsTarget ( ) ;

i f ( r s != null && rs . s i z e ( ) > 0) {for ( RuleExclus ion r : r s ) {

Alternat iveAnswer as = r . getAlternat iveAnswerSource ( ) ;

Question qs = as . getQuest ion ( ) ;

Evidence asa ;

tmp = new ExclusionBean ( qs . getQuest ion ( ) , as

210

Page 229: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

. getAnswer ( ) , ”” , ” out” ) ;

870 i f ( qs . getQuest ionId ( ) == re ferenceAnswerSet

. getQuest ion ( ) . getQuest ionId ( ) ) {i f ( f i l l i n g s . containsKey ( as . getAnswerId ( ) ) ) {

Boolean yn = ( Boolean ) f i l l i n g s . get (

as . getAnswerId ( ) ) . getYesno ( ) . getValue ( ) ;

i f ( yn != null && yn == true ) {tmp . s e t T r i g g e r ( ” t r i g g e r e d ” ) ;

exded . add (tmp) ;

} else {tmp . s e t T r i g g e r ( ”may t r i g g e r ” ) ;

880 may exded . add (tmp) ;

}} else

may exded . add (tmp) ;

} else {asa = questionMngr . getAnswsetAnsw ( r e f e r e n c e P r o j e c t ,

as ) ;

tmp = new ExclusionBean ( qs . getQuest ion ( ) , as

. getAnswer ( ) , ”” , ” in ” ) ;

i f ( asa != null ) {890 i f ( asa . getResponse ( ) . equa l s ( ” yes ” ) ) {

tmp . s e t T r i g g e r ( ” t r i g g e r e d ” ) ;

exded . add (tmp) ;

} else {System . out . p r i n t l n ( ” Regola non a p p l i c a b i l e ”

+ as . getAnswerId ( ) ) ;

tmp . s e t T r i g g e r ( ”may t r i g g e r ” ) ;

may exded . add (tmp) ;

}} else {

900 System . out . p r i n t l n ( ” Risposta non data ”

+ as . getAnswerId ( ) ) ;

may exded . add (tmp) ;

}}

}}r s = a . getRuleExc lus ionsSource ( ) ;

i f ( r s != null && rs . s i z e ( ) > 0) {for ( RuleExclus ion r : r s ) {

910 Alternat iveAnswer as = r . getAlternat iveAnswerTarget ( ) ;

Question qs = as . getQuest ion ( ) ;

Evidence asa ;

tmp = new ExclusionBean ( qs . getQuest ion ( ) , as

. getAnswer ( ) , ”” , ” out” ) ;

i f ( qs . getQuest ionId ( ) == re ferenceAnswerSet

. getQuest ion ( ) . getQuest ionId ( ) ) {i f ( f i l l i n g s . containsKey ( as . getAnswerId ( ) ) ) {

Boolean yn = ( Boolean ) f i l l i n g s . get (

as . getAnswerId ( ) ) . getYesno ( ) . getValue ( ) ;

920 i f ( yn != null && yn == true ) {tmp . s e t T r i g g e r ( ” t r i g g e r e d ” ) ;

exded . add (tmp) ;

} else {tmp . s e t T r i g g e r ( ”may t r i g g e r ” ) ;

211

Page 230: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

may exded . add (tmp) ;

}} else

may exded . add (tmp) ;

} else {930 asa = questionMngr . getAnswsetAnsw ( r e f e r e n c e P r o j e c t ,

as ) ;

i f ( asa != null ) {i f ( asa . getResponse ( ) . equa l s ( ” yes ” ) ) {

tmp . s e t T r i g g e r ( ” t r i g g e r e d ” ) ;

exded . add (tmp) ;

} else {tmp . s e t T r i g g e r ( ”may t r i g g e r ” ) ;

System . out . p r i n t l n ( ” Regola non a p p l i c a b i l e ”

+ as . getAnswerId ( ) ) ;

940 may exded . add (tmp) ;

}} else {

System . out . p r i n t l n ( ” Risposta non data ”

+ as . getAnswerId ( ) ) ;

may exded . add (tmp) ;

}}

}}

950 St r ing k = ” excluded ” ;

keys . add ( k ) ;

r i s . put (k , exded ) ;

k = ” may excluded ” ;

keys . add ( k ) ;

r i s . put (k , may exded ) ;

}return r i s ;

960 }

public HashMap<Str ing , L i s t<ExclusionBean>> showRulesFrom (

HashMap<Integer , F i l l ingBean> f i l l i n g s , I n t e g e r a id ) {ExclusionBean tmp ;

LinkedList<Str ing> keys = new LinkedList<Str ing >() ;

HashMap<Str ing , L i s t<ExclusionBean>> r i s = new HashMap<Str ing ,

L i s t<ExclusionBean >>() ;

LinkedList<ExclusionBean> exdes = new LinkedList<ExclusionBean >() ;

L i s t<AlternativeAnswer> ans = re f e r enceQue s t i on . getAlternat iveAnswers ( ) ;

for ( Alternat iveAnswer a : ans )

970 i f ( a . getAnswerId ( ) == aid ) {List<RuleExclusion> r s = a . getRuleExc lus ionsTarget ( ) ;

i f ( r s != null && rs . s i z e ( ) > 0) {for ( RuleExclus ion r : r s ) {

Alternat iveAnswer as = r . getAlternat iveAnswerSource ( ) ;

Question qs = as . getQuest ion ( ) ;

tmp = new ExclusionBean ( qs . getQuest ion ( ) , as

. getAnswer ( ) , ”” , ” out” ) ;

i f ( qs . getQuest ionId ( ) == re f e r enceQues t i on

. getQuest ionId ( ) ) {

212

Page 231: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

980 exdes . add (tmp) ;

} else {exdes . add (tmp) ;

}}

}r s = a . getRuleExc lus ionsSource ( ) ;

i f ( r s != null && rs . s i z e ( ) > 0) {for ( RuleExclus ion r : r s ) {

Alternat iveAnswer as = r . getAlternat iveAnswerTarget ( ) ;

990 Question qs = as . getQuest ion ( ) ;

tmp = new ExclusionBean ( qs . getQuest ion ( ) , as

. getAnswer ( ) , ”” , ” out” ) ;

i f ( qs . getQuest ionId ( ) == re f e r enceQues t i on

. getQuest ionId ( ) ) {exdes . add (tmp) ;

} else {exdes . add (tmp) ;

}}

1000 }St r ing k = ” exc ludes ” ;

keys . add ( k ) ;

r i s . put (k , exdes ) ;

}return r i s ;

}

public StreamResource exportPie1 ( ) {1010 i f ( resourcePNG1 == null )

resourcePNG1 = new StreamResource (null , ” p i e1 . png” , appl ) ;

StreamResource . StreamSource source = new StreamResource . StreamSource ( ) {public InputStream getStream ( ) {

St r ing e r r o r = ” e r r o r ” ;

byte [ ] da t i = e r r o r . getBytes ( ) ;

da t i = getPlotBytes ( getStreamPieQ (null , 360 , 350) ) ;

i f ( da t i == null )

da t i = e r r o r . getBytes ( ) ;

return new ByteArrayInputStream ( dat i ) ;

1020 }} ;

resourcePNG1 . setStreamSource ( source ) ;

resourcePNG1 . setMIMEType( ” image/png” ) ;

resourcePNG1 . setCacheTime(−1) ;

return resourcePNG1 ;

}

private St r ing de f in i t i onOfContex t = ” D e f i n i t i o n o f C o n t e x t ” ;

1030 public BufferedImage getStreamPieFina l ( Mpackage pkg , int w, int h) {boolean isContextPAckage = fa l se ;

i f ( pkg != null && pkg . getCanonicalName ( ) != null )

isContextPAckage = pkg . getCanonicalName ( ) . conta in s (

de f in i t i onOfContex t ) ;

LinkedHashMap<Str ing , Integer> mappa = new LinkedHashMap<Str ing , Integer >() ;

213

Page 232: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

mappa . put ( Quest ionStatus .TO SPECIFY. toUpperCase ( ) , 0) ;

mappa . put ( Quest ionStatus .YET TO ANALYZE. toUpperCase ( ) , 0) ;

i f ( ! isContextPAckage ) {mappa . put ( Quest ionStatus .ACCEPTED. toUpperCase ( ) , 0) ;

1040 mappa . put ( Quest ionStatus .REJECTED. toUpperCase ( ) , 0) ;

mappa . put ( Quest ionStatus .PART AGREED. toUpperCase ( ) , 0) ;

}List<Question> q s t s = new ArrayList<Question >(pkg == null ? getLi s tData ( ) :

getLi s tData ( pkg ) ) ;

for ( Question q : q s t s ) {AnswerSet as = getAnswerSetIsPresent ( q . getQuest ionId ( ) ) ;

S t r ing s t a t e = Quest ionStatus .TO SPECIFY. toUpperCase ( ) ;

i f ( as != null && as . g e tF ina lS ta tu s ( ) != null )

s t a t e = as . g e tF ina lS ta tu s ( ) ;

s t a t e = s t a t e . toUpperCase ( ) ;

1050 i f ( ! mappa . containsKey ( s t a t e ) ) {i f ( ! isContextPAckage )

mappa . put ( s ta te , 1) ;

} else

mappa . put ( s ta te , 1 + mappa . get ( s t a t e ) ) ;

}Color [ ] c o l o r s = { new Color (255 , 127 , 42) , Color . yel low , Color . green ,

Color . red , new Color (255 , 92 , 255) , new Color (92 , 255 , 255) ,

Color . orange , new Color (255 , 178 , 178) , new Color (255 , 92 , 92) ,

new Color (92 , 92 , 255) , new Color (92 , 255 , 92) ,

1060 new Color (255 , 255 , 92) , Color . l i ghtGray } ;

i f ( isContextPAckage ) {LinkedHashMap<Str ing , Integer> mappa2 = new LinkedHashMap<Str ing , Integer >() ;

mappa2 . put ( ”TO SPECIFY” , mappa . get ( Quest ionStatus .TO SPECIFY

. toUpperCase ( ) ) ) ;

mappa2 . put ( ”SPECIFIED” , mappa . get ( Quest ionStatus .YET TO ANALYZE

. toUpperCase ( ) ) ) ;

mappa = mappa2 ;

}PieChart pdf = new PieChart (mappa , ” Fina l s t a t u s ” , c o l o r s ) ;

1070 return pdf . ge tP lo t (w, h) ;

}

public BufferedImage getStreamPieQ ( Mpackage pkg , int w, int h) {boolean isContextPAckage = fa l se ;

i f ( pkg != null && pkg . getCanonicalName ( ) != null )

isContextPAckage = pkg . getCanonicalName ( ) . conta in s (

de f in i t i onOfContex t ) ;

LinkedHashMap<Str ing , Integer> mappa = new LinkedHashMap<Str ing , Integer >() ;

mappa . put ( Quest ionStatus .TO SPECIFY. toUpperCase ( ) , 0) ;

1080 mappa . put ( Quest ionStatus .YET TO ANALYZE. toUpperCase ( ) , 0) ;

i f ( ! isContextPAckage ) {mappa . put ( Quest ionStatus .ACCEPTED. toUpperCase ( ) , 0) ;

mappa . put ( Quest ionStatus .REJECTED. toUpperCase ( ) , 0) ;

mappa . put ( Quest ionStatus .PART AGREED. toUpperCase ( ) , 0) ;

}List<Question> q s t s = new ArrayList<Question >(pkg == null ? getLi s tData ( ) :

getLi s tData ( pkg ) ) ;

for ( Question q : q s t s ) {AnswerSet as = getAnswerSetIsPresent ( q . getQuest ionId ( ) ) ;

S t r ing s t a t e = Quest ionStatus .TO SPECIFY. toUpperCase ( ) ;

214

Page 233: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

1090 i f ( as != null && as . getApprovat ionStatusFina l ( ) != null )

s t a t e = as . getApprovat ionStatusFina l ( ) ;

s t a t e = s t a t e . toUpperCase ( ) ;

i f ( ! mappa . containsKey ( s t a t e ) ) {i f ( ! isContextPAckage )

mappa . put ( s ta te , 1) ;

} else

mappa . put ( s ta te , 1 + mappa . get ( s t a t e ) ) ;

}Color [ ] c o l o r s = { new Color (255 , 127 , 42) , Color . yel low , Color . green ,

1100 Color . red , new Color (255 , 92 , 255) , new Color (92 , 255 , 255) ,

Color . orange , new Color (255 , 178 , 178) , new Color (255 , 92 , 92) ,

new Color (92 , 92 , 255) , new Color (92 , 255 , 92) ,

new Color (255 , 255 , 92) , Color . l i ghtGray } ;

i f ( isContextPAckage ) {LinkedHashMap<Str ing , Integer> mappa2 = new LinkedHashMap<Str ing , Integer >() ;

mappa2 . put ( ”TO SPECIFY” , mappa . get ( Quest ionStatus .TO SPECIFY

. toUpperCase ( ) ) ) ;

mappa2 . put ( ”SPECIFIED” , mappa . get ( Quest ionStatus .YET TO ANALYZE

. toUpperCase ( ) ) ) ;

1110 mappa = mappa2 ;

}PieChart pdf = new PieChart (mappa , ” Evidence s t a t u s ” , c o l o r s ) ;

return pdf . ge tP lo t (w, h) ;

}

public BufferedImage getStreamPieQD ( Mpackage pkg , int w, int h) {LinkedHashMap<Str ing , Integer> mappa = new LinkedHashMap<Str ing , Integer >() ;

mappa . put ( Quest ionStatus .TO SPECIFY. toUpperCase ( ) , 0) ;

mappa . put ( Quest ionStatus .YET TO ANALYZE. toUpperCase ( ) , 0) ;

1120 mappa . put ( Quest ionStatus .ACCEPTED. toUpperCase ( ) , 0) ;

mappa . put ( Quest ionStatus .REJECTED. toUpperCase ( ) , 0) ;

mappa . put ( Quest ionStatus .PART AGREED. toUpperCase ( ) , 0) ;

L i s t<Question> q s t s = pkg == null ? getLis tData ( ) : getLi s tData ( pkg ) ;

Question remove = null ;

i f ( pkg == null && i s S i l Q u e s t i o n n a i r e ( ) ) {int qid = r e f e r e n c e P r o j e c t . ge tQues t i onna i r e ( ) . g e tS i lQue s t i on ( )

. getQuest ionId ( ) ;

for ( Question q : q s t s )

i f ( q . getQuest ionId ( ) == qid )

1130 remove = q ;

}i f ( remove != null )

q s t s . remove ( remove ) ;

for ( Question q : q s t s ) {AnswerSet as = getAnswerSetIsPresent ( q . getQuest ionId ( ) ) ;

S t r ing s t a t e = Quest ionStatus .TO SPECIFY. toUpperCase ( ) ;

i f ( as != null && as . getDel ivApprovat ionStatus ( ) != null )

s t a t e = as . getDe l ivApprovat ionStatus ( ) ;

s t a t e = s t a t e . toUpperCase ( ) ;

1140 i f ( ! mappa . containsKey ( s t a t e ) )

mappa . put ( s ta te , 1) ;

else

mappa . put ( s ta te , 1 + mappa . get ( s t a t e ) ) ;

}Color [ ] c o l o r s = { new Color (255 , 127 , 42) , Color . yel low , Color . green ,

215

Page 234: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

Color . red , new Color (255 , 92 , 255) , new Color (92 , 255 , 255) ,

Color . orange , new Color (255 , 178 , 178) , new Color (255 , 92 , 92) ,

new Color (92 , 92 , 255) , new Color (92 , 255 , 92) ,

new Color (255 , 255 , 92) , Color . l i ghtGray } ;

1150 PieChart pdf = new PieChart (mappa , ” D e l i v e r a b l e s t a t u s ” , c o l o r s ) ;

return pdf . ge tP lo t (w, h) ;

}

public StreamResource exportPie2 ( ) {i f ( resourcePNG2 == null )

resourcePNG2 = new StreamResource (null , ” p i e2 . png” , appl ) ;

StreamResource . StreamSource source = new StreamResource . StreamSource ( ) {public InputStream getStream ( ) {

St r ing e r r o r = ” e r r o r ” ;

1160 byte [ ] da t i = e r r o r . getBytes ( ) ;

da t i = getPlotBytes ( getStreamPieQD (null , 360 , 350) ) ;

i f ( da t i == null )

da t i = e r r o r . getBytes ( ) ;

return new ByteArrayInputStream ( dat i ) ;

}} ;

resourcePNG2 . setStreamSource ( source ) ;

resourcePNG2 . setMIMEType( ” image/png” ) ;

resourcePNG2 . setCacheTime(−1) ;

1170 return resourcePNG2 ;

}

public BufferedImage getStreamPieD ( Mpackage pkg , int w, int h) {LinkedHashMap<Str ing , Integer> mappa = new LinkedHashMap<Str ing , Integer >() ;

mappa . put ( AnswerStatus .PROPOSED. toUpperCase ( ) , 0) ;

mappa . put ( AnswerStatus .ACCEPTED. toUpperCase ( ) , 0) ;

mappa . put ( AnswerStatus .REJECTED. toUpperCase ( ) , 0) ;

mappa . put ( AnswerStatus .PART AGREED. toUpperCase ( ) , 0) ;

L i s t<Question> q s t s = pkg == null ? getLis tData ( ) : getLi s tData ( pkg ) ;

1180 Question remove = null ;

i f ( pkg == null && i s S i l Q u e s t i o n n a i r e ( ) ) {int qid = r e f e r e n c e P r o j e c t . ge tQues t i onna i r e ( ) . g e tS i lQue s t i on ( )

. getQuest ionId ( ) ;

for ( Question q : q s t s )

i f ( q . getQuest ionId ( ) == qid )

remove = q ;

}i f ( remove != null )

q s t s . remove ( remove ) ;

1190 for ( Question q : q s t s ) {AnswerSet as = getAnswerSetIsPresent ( q . getQuest ionId ( ) ) ;

S t r ing s t a t e = AnswerStatus .PROPOSED. toUpperCase ( ) ;

i f ( as != null && as . getAnswsetAnsws ( ) != null ) {List<Evidence> aas = as . getAnswsetAnsws ( ) ;

for ( Evidence a : aas ) {i f ( a . getApprovat ionDel ivStatus ( ) != null

&& ! a . getApprovat ionDel ivStatus ( ) . equa l s ( ”” ) )

s t a t e = a . getApprovat ionDel ivStatus ( ) ;

s t a t e = s t a t e . toUpperCase ( ) ;

1200 i f ( ! mappa . containsKey ( s t a t e ) )

mappa . put ( s ta te , 1) ;

216

Page 235: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

else

mappa . put ( s ta te , 1 + mappa . get ( s t a t e ) ) ;

}}

}Color [ ] c o l o r s = { Color . yel low , Color . green , Color . red ,

new Color (255 , 92 , 255) , new Color (92 , 255 , 255) , Color . orange ,

new Color (255 , 178 , 178) , new Color (255 , 92 , 92) ,

1210 new Color (92 , 92 , 255) , new Color (92 , 255 , 92) ,

new Color (255 , 255 , 92) , Color . l i ghtGray } ;

PieChart pdf = new PieChart (mappa , ” Evidence Mapping agreement ” , c o l o r s ) ;

return pdf . ge tP lo t (w, h) ;

}

public StreamResource exportPie3 ( ) {i f ( resourcePNG3 == null )

resourcePNG3 = new StreamResource (null , ” p i e3 . png” , appl ) ;

StreamResource . StreamSource source = new StreamResource . StreamSource ( ) {1220 public InputStream getStream ( ) {

St r ing e r r o r = ” e r r o r ” ;

byte [ ] da t i = e r r o r . getBytes ( ) ;

da t i = getPlotBytes ( getStreamPieFina l (null , 360 , 350) ) ;

i f ( da t i == null )

da t i = e r r o r . getBytes ( ) ;

return new ByteArrayInputStream ( dat i ) ;

}} ;

resourcePNG3 . setStreamSource ( source ) ;

1230 resourcePNG3 . setMIMEType( ” image/png” ) ;

resourcePNG3 . setCacheTime(−1) ;

return resourcePNG3 ;

}

public BufferedImage getStreamPieA ( Mpackage pkg , int w, int h) {boolean isContextPAckage = fa l se ;

i f ( pkg != null && pkg . getCanonicalName ( ) != null )

isContextPAckage = pkg . getCanonicalName ( ) . conta in s (

de f in i t i onOfContex t ) ;

1240 LinkedHashMap<Str ing , Integer> mappa = new LinkedHashMap<Str ing , Integer >() ;

i f ( isContextPAckage )

mappa . put ( ”NOT PROPOSED” , 0) ;

mappa . put ( AnswerStatus .PROPOSED. toUpperCase ( ) , 0) ;

i f ( ! isContextPAckage ) {mappa . put ( AnswerStatus .PROPOSED. toUpperCase ( ) , 0) ;

mappa . put ( AnswerStatus .ACCEPTED. toUpperCase ( ) , 0) ;

mappa . put ( AnswerStatus .REJECTED. toUpperCase ( ) , 0) ;

mappa . put ( AnswerStatus .PART AGREED. toUpperCase ( ) , 0) ;

}1250 List<Question> q s t s = pkg == null ? getLis tData ( ) : getLi s tData ( pkg ) ;

Question remove = null ;

i f ( pkg == null && i s S i l Q u e s t i o n n a i r e ( ) ) {int qid = r e f e r e n c e P r o j e c t . ge tQues t i onna i r e ( ) . g e tS i lQue s t i on ( )

. getQuest ionId ( ) ;

for ( Question q : q s t s )

i f ( q . getQuest ionId ( ) == qid )

remove = q ;

217

Page 236: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}i f ( remove != null )

1260 q s t s . remove ( remove ) ;

for ( Question q : q s t s ) {AnswerSet as = getAnswerSetIsPresent ( q . getQuest ionId ( ) ) ;

S t r ing s t a t e = AnswerStatus .PROPOSED. toUpperCase ( ) ;

i f ( as != null && as . getAnswsetAnsws ( ) != null ) {List<Evidence> aas = as . getAnswsetAnsws ( ) ;

for ( Evidence a : aas ) {i f ( ! isContextPAckage ) {

i f ( a . getApprovat ionStatus ( ) != null

&& ! a . getApprovat ionStatus ( ) . equa l s ( ”” ) )

1270 s t a t e = a . getApprovat ionStatus ( ) ;

} else {i f ( a . getResponse ( ) != null

&& ! a . getResponse ( ) . equa l s IgnoreCase ( ” yes ” ) )

s t a t e = ”NOT PROPOSED” ;

}s t a t e = s t a t e . toUpperCase ( ) ;

i f ( ! mappa . containsKey ( s t a t e ) )

mappa . put ( s ta te , 1) ;

else

1280 mappa . put ( s ta te , 1 + mappa . get ( s t a t e ) ) ;

}}

}Color [ ] c o l o r s = { Color . yel low , Color . green , Color . red ,

new Color (255 , 92 , 255) , new Color (92 , 255 , 255) , Color . orange ,

new Color (255 , 178 , 178) , new Color (255 , 92 , 92) ,

new Color (92 , 92 , 255) , new Color (92 , 255 , 92) ,

new Color (255 , 255 , 92) , Color . l i ghtGray } ;

PieChart pdf = new PieChart (mappa , ” D e l i v e r a b l e s t a t u s ” , c o l o r s ) ;

1290 return pdf . ge tP lo t (w, h) ;

}

public StreamResource exportPieQRefPackage ( ) {return exportPieQPackage ( re f e rencePackage ) ;

}

public StreamResource exportPieQPackage ( f ina l Mpackage pkg ) {i f ( ! resoursePieQPackage . containsKey ( pkg ) ) {

resoursePieQPackage . put ( pkg , new StreamResource (null , ” pieQ pkg ”

1300 + pkg . getPackageId ( ) + ” . png” , appl ) ) ;

}StreamResource . StreamSource source = new StreamResource . StreamSource ( ) {

public InputStream getStream ( ) {St r ing e r r o r = ” e r r o r ” ;

byte [ ] da t i = e r r o r . getBytes ( ) ;

da t i = getPlotBytes ( getStreamPieQ ( pkg , 360 , 350) ) ;

i f ( da t i == null )

da t i = e r r o r . getBytes ( ) ;

return new ByteArrayInputStream ( dat i ) ;

1310 }} ;

StreamResource r = resoursePieQPackage . get ( pkg ) ;

r . setStreamSource ( source ) ;

218

Page 237: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

r . setMIMEType( ” image/png” ) ;

r . setCacheTime(−1) ;

return r ;

}

public StreamResource exportPieARefPackage ( ) {1320 return exportPieAPackage ( re f e rencePackage ) ;

}

public StreamResource exportPieDRefPackage ( ) {return exportPieDPackage ( re f e rencePackage ) ;

}

public StreamResource exportPieAPackage ( f ina l Mpackage pkg ) {i f ( ! resoursePieAPackage . containsKey ( pkg ) ) {

resoursePieAPackage . put ( pkg , new StreamResource (null , ” pieA pkg ”

1330 + pkg . getPackageId ( ) + ” . png” , appl ) ) ;

}StreamResource . StreamSource source = new StreamResource . StreamSource ( ) {

public InputStream getStream ( ) {St r ing e r r o r = ” e r r o r ” ;

byte [ ] da t i = e r r o r . getBytes ( ) ;

da t i = getPlotBytes ( getStreamPieQD ( pkg , 360 , 350) ) ;

i f ( da t i == null )

da t i = e r r o r . getBytes ( ) ;

return new ByteArrayInputStream ( dat i ) ;

1340 }} ;

StreamResource r = resoursePieAPackage . get ( pkg ) ;

r . setStreamSource ( source ) ;

r . setMIMEType( ” image/png” ) ;

r . setCacheTime(−1) ;

return r ;

}

public byte [ ] getPlotBytes ( BufferedImage image ) {1350 ByteArrayOutputStream imagebuf f e r = new ByteArrayOutputStream ( ) ;

try {imagebuf f e r = new ByteArrayOutputStream ( ) ;

ImageIO . wr i t e ( image , ”png” , imagebuf f e r ) ;

return imagebuf f e r . toByteArray ( ) ;

} catch ( IOException e ) {return null ;

}}

1360public StreamResource exportPieDPackage ( f ina l Mpackage pkg ) {

i f ( ! resourcePieDPackage . containsKey ( pkg ) ) {resourcePieDPackage . put ( pkg , new StreamResource (null , ” pieD pkg ”

+ pkg . getPackageId ( ) + ” . png” , appl ) ) ;

}StreamResource . StreamSource source = new StreamResource . StreamSource ( ) {

public InputStream getStream ( ) {St r ing e r r o r = ” e r r o r ” ;

byte [ ] da t i = e r r o r . getBytes ( ) ;

219

Page 238: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

1370 dat i = getPlotBytes ( getStreamPieFina l ( pkg , 360 , 350) ) ;

i f ( da t i == null )

da t i = e r r o r . getBytes ( ) ;

return new ByteArrayInputStream ( dat i ) ;

}} ;

StreamResource r = resourcePieDPackage . get ( pkg ) ;

r . setStreamSource ( source ) ;

r . setMIMEType( ” image/png” ) ;

r . setCacheTime(−1) ;

1380 return r ;

}

public Resource exportEcore ( ) {i f ( r e sourceEcore == null )

r e sourceEcore = new StreamResource (null , ” export . e co re ” , appl ) ;

StreamResource . StreamSource source = new StreamResource . StreamSource ( ) {public InputStream getStream ( ) {

St r ing e r r o r = ” e r r o r ” ;

byte [ ] da t i = e r r o r . getBytes ( ) ;

1390 EcoreDiagModi f ier em = new EcoreDiagModi f ier ( r e f e r e n c e P r o j e c t ,

F i l l o u t V a l i d a t i o n C t r l . this ) ;

da t i = em. getEcore ( ) ;

return new ByteArrayInputStream ( dat i ) ;

}} ;

r e sourceEcore . setStreamSource ( source ) ;

r e sourceEcore . setMIMEType( ” text / ecore ” ) ;

r e sourceEcore . setCacheTime(−1) ;

return r e sourceEcore ;

1400 }

public Resource exportEcoreDiag ( ) {i f ( resourceEcoreDiag == null )

resourceEcoreDiag = new StreamResource (null , ”model . z ip ” , appl ) ;

StreamResource . StreamSource source = new StreamResource . StreamSource ( ) {public InputStream getStream ( ) {

St r ing e r r o r = ” e r r o r ” ;

byte [ ] da t i = e r r o r . getBytes ( ) ;

EcoreDiagModi f ier em = new EcoreDiagModi f ier ( r e f e r e n c e P r o j e c t ,

1410 F i l l o u t V a l i d a t i o n C t r l . this ) ;

da t i = em. getZip ( ) ;

return new ByteArrayInputStream ( dat i ) ;

}} ;

r e sourceEcoreDiag . setStreamSource ( source ) ;

resourceEcoreDiag . setMIMEType( ” a p p l i c a t i o n / z ip ” ) ;

resourceEcoreDiag . setCacheTime(−1) ;

return resourceEcoreDiag ;

}1420

public Agreement ge tPro j e c t ( ) {return r e f e r e n c e P r o j e c t ;

}

220

Page 239: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public Question getReferenceQuest ion ( ) {questionMngr . r e f r e s h ( r e f e r enceQues t i on ) ;

return r e f e r enceQues t i on ;

1430 }

public AnswerSet getReferenceAnswset ( ) {questionMngr . r e f r e s h ( re fe renceAnswerSet ) ;

return re f e renceAnswerSet ;

}

public double g e t P r i o r i t y ( Mpackage pkg ) {double r e s = 0 ;

1440 List<Question> qs = getLis tData ( pkg ) ;

int i = 0 ;

for ( Question q : qs ) {AnswerSet as = questionMngr . getAnswerSet ( q . getQuest ionId ( ) ) ;

r e s += as . g e t P r i o r i t y ( ) ;

i ++;

}r e s /= i ;

MpackageRank pr = new MpackageRank ( ) ;

pr . setMpackage ( pkg ) ;

1450 pr . s e t P r i o r i t y ( r e s ) ;

pr . setRank (0 ) ;

packagePr io r i ty . put ( pkg , pr ) ;

return r e s ;

}

public class MpackageRank {private Mpackage mpackage ;

private double p r i o r i t y ;

private int rank ;

1460public Mpackage getMpackage ( ) {

return mpackage ;

}

public void setMpackage ( Mpackage mpackage ) {this . mpackage = mpackage ;

}

public double g e t P r i o r i t y ( ) {1470 return p r i o r i t y ;

}

public void s e t P r i o r i t y (double p r i o r i t y ) {this . p r i o r i t y = p r i o r i t y ;

}

public int getRank ( ) {return rank ;

}1480

public void setRank ( int rank ) {

221

Page 240: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

this . rank = rank ;

}}

public ValueChangeListener g e t P a c k a g e F i l l i n g S e l e c t e d ( ) {return new Property . ValueChangeListener ( ) {

@Override

public void valueChange ( ValueChangeEvent event ) {1490 r e f e r encePackage = ( Mpackage ) qstUI . packageLis t . getValue ( ) ;

qstUI . q u e s t i o n s L i s t ( ) ;

}} ;

}

public ValueChangeListener ge tPackageVa l idat i onSe l e c t ed ( ) {return new Property . ValueChangeListener ( ) {

@Override

public void valueChange ( ValueChangeEvent event ) {1500 r e f e r encePackage = ( Mpackage ) va l idUI . packageLis t . getValue ( ) ;

va l idUI . q u e s t i o n s L i s t ( ) ;

}} ;

}

public void q u e s t i o n S i l D e t a i l s ( ) {i f ( i s S i l Q u e s t i o n n a i r e ( ) ) {

I n t e g e r qid = r e f e r e n c e P r o j e c t . ge tQues t i onna i r e ( ) . g e tS i lQue s t i on ( )

. getQuest ionId ( ) ;

1510 AnswerSet a = questionMngr . getAnswerSet ( qid ) ;

i f ( a != null ) {I n t e g e r a id = a . getAnswerSetId ( ) ;

System . out . p r i n t l n ( ” e un q u e s t i o n a r i o SIL −> r i s p o n d i a ” + qid

+ ” / answset = ” + aid ) ;

re f e renceAnswerSet = answerSetForProject . get ( a id ) ;

i f ( re fe renceAnswerSet != null ) {r e f e r enceQue s t i on = re ferenceAnswerSet . getQuest ion ( ) ;

qstUI . q u e s t i o n D e t a i l s ( fa l se ) ;

} else {1520 System . out . p r i n t l n ( ” answerSetForProject non cont i ene ”

+ aid ) ;

}} else {

System . out

. p r i n t l n ( ” e un q u e s t i o n a r i o SIL ma non c ’ e l ’ answerSET per ”

+ qid ) ;

}} else

System . out . p r i n t l n ( ”non e un q u e s t i o n a r i o SIL” ) ;

1530 }

public boolean i s S i l Q u e s t i o n n a i r e ( ) {i f ( r e f e r e n c e P r o j e c t . ge tQues t i onna i r e ( ) . g e tS i lQue s t i on ( ) != null )

return true ;

return fa l se ;

}

222

Page 241: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public St r ing a c t u a l S i l L e v e l ( ) {i f ( i s S i l Q u e s t i o n n a i r e ( ) ) {

1540 I n t e g e r qid = r e f e r e n c e P r o j e c t . ge tQues t i onna i r e ( ) . g e tS i lQue s t i on ( )

. getQuest ionId ( ) ;

AnswerSet aaa = questionMngr . getAnswerSet ( qid ) ;

i f ( aaa == null ) {return null ;

} else {for ( Evidence a : aaa . getAnswsetAnsws ( ) ) {

i f ( a . getResponse ( ) != null

&& a . getResponse ( ) . equa l s IgnoreCase ( ” yes ” ) ) {return a . getAlternat iveAnswer ( ) . getAnswer ( ) ;

1550 }}return null ;

}}return null ;

}

public void saveDel iverablesMapping ( Evidence a ,

ArrayList<Del iverab leEvidence> dats ,

1560 Del ive rab l eContentHi s to ry h i s t ) {LoggedUser l u s e r = ( LoggedUser ) appl . getUser ( ) ;

User user = l u s e r . getUserObj ( ) ;

Role r = UserManager . getRo leForPro jec t ( user , r e f e r e n c e P r o j e c t ) ;

boolean i s S u p p l i e r = ( r . g e tRo l eDesc r ip t i on ( )

. equa l s IgnoreCase ( RoleTypes .SUPPLIER) ) ;

i f ( r == null | | dats == null )

return ;

S t r ing h i s tAct i on = ”” ;

for ( De l ive rab l eEv idence de : dats ) {1570 try {

de l ive rab l e sMngr . saveDe l ive rab l eEv idence ( de ) ;

i f ( de . ge t Inc luded ( ) )

h i s tAct i on += de . g e t D e l i v e r a b l e ( ) . getName ( ) + ”\n” ;

} catch ( SaveException e ) {}

}i f ( h i s t != null ) {

i f ( h i s tAct i on . l ength ( ) == 0)

h i s tAct i on = ”No d e l i v e r a b l e has been s e l e c t e d ” ;

1580 else

h i s tAct i on = ”The user has s e l e c t e d the f o l l o w i n g d e l i v e r a b l e s :\n”

+ h i s tAct i on ;

i f ( ! i s S u p p l i e r )

h i s tAct i on = ”Changes comments on mapping” ;

h i s t . setAnswsetAnsw ( a ) ;

h i s t . setModtime (new Date ( ) ) ;

h i s t . s e tUser ( user ) ;

h i s t . s e tAct ion ( h i s tAct i on ) ;

}1590 try {

de l ive rab l e sMngr . saveDe l i ve rab l eEv idenceHi s t ( h i s t ) ;

} catch ( SaveException e ) {}

223

Page 242: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

AnswerSet as = a . getAnswerSet ( ) ;

S t r ing s t a t u s = as . getDel ivApprovat ionStatus ( ) ;

i f ( s t a t u s == null | | s t a t u s . equa l s ( Quest ionStatus .TO SPECIFY) )

as . se tDe l ivApprovat ionStatus ( Quest ionStatus .YET TO ANALYZE) ;

de l ive rab l e sMngr . r e f r e s h ( a ) ;

qstUI . que s t i onDeta i l sEv idence ( false , a ) ;

1600 }

public void saveDel iverablesMappingApprov ( Evidence a ,

De l ive rab l eContentHi s to ry h i s t ) {LoggedUser l u s e r = ( LoggedUser ) appl . getUser ( ) ;

User user = l u s e r . getUserObj ( ) ;

h i s t . setAnswsetAnsw ( a ) ;

h i s t . setModtime (new Date ( ) ) ;

h i s t . s e tUser ( user ) ;

h i s t . s e tAct ion ( ”Agreement s e t to : ” + a . getApprovat ionDel ivStatus ( ) ) ;

1610 a . setApprovDelivLastmod (new Date ( ) ) ;

a . setApprovDel ivUser ( user ) ;

try {questionMngr . saveAnswsetAnsw ( a ) ;

} catch ( SaveException e1 ) {}

try {de l ive rab l e sMngr . saveDe l i ve rab l eEv idenceHi s t ( h i s t ) ;

} catch ( SaveException e ) {1620 }

HashMap<Str ing , Integer> l e v e l = new HashMap<Str ing , Integer >() ;

l e v e l . put ( Quest ionStatus . TO SPECIFY, 0) ;

l e v e l . put ( Quest ionStatus .YET TO ANALYZE, 0) ;

l e v e l . put ( Quest ionStatus .REJECTED, 0) ;

l e v e l . put ( Quest ionStatus .PART AGREED, 0) ;

l e v e l . put ( Quest ionStatus .ACCEPTED, 0) ;

for ( Evidence as : a . getAnswerSet ( ) . getAnswsetAnsws ( ) ) {St r ing k = as . getApprovat ionDel ivStatus ( ) ;

i f ( k != null && l e v e l . containsKey ( k ) )

1630 l e v e l . put (k , l e v e l . get ( k ) + 1) ;

else

System . out . p r i n t l n ( ”Chiave non trovata : ” + k ) ;

}St r ing s t a t u s ;

i f ( l e v e l . get ( Quest ionStatus .ACCEPTED) > 0

&& l e v e l . get ( Quest ionStatus .REJECTED) == 0

&& l e v e l . get ( Quest ionStatus .PART AGREED) == 0)

s t a t u s = Quest ionStatus .ACCEPTED;

else i f ( l e v e l . get ( Quest ionStatus .PART AGREED) > 0)

1640 s t a t u s = Quest ionStatus .PART AGREED;

else i f ( l e v e l . get ( Quest ionStatus .REJECTED) > 0

&& ( l e v e l . get ( Quest ionStatus .PART AGREED) > 0 | | l e v e l

. get ( Quest ionStatus .ACCEPTED) > 0) )

s t a t u s = Quest ionStatus .PART AGREED;

else i f ( l e v e l . get ( Quest ionStatus .REJECTED) > 0

&& l e v e l . get ( Quest ionStatus .PART AGREED) == 0

&& l e v e l . get ( Quest ionStatus .ACCEPTED) == 0)

s t a t u s = Quest ionStatus .REJECTED;

else

224

Page 243: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

1650 s t a t u s = Quest ionStatus .PART AGREED;

AnswerSet as2 = a . getAnswerSet ( ) ;

as2 . se tDe l ivApprovat ionStatus ( s t a t u s ) ;

try {questionMngr . saveAnswerSet ( as2 ) ;

} catch ( SaveException e1 ) {}List<Del ive rab l e> l = de l ive rab l e sMngr . v iewAl l ( ) ;

for ( D e l i v e r a b l e d : l ) {List<Del iverab leEvidence> l e = d . ge tDe l i v e rab l eEv idence s ( ) ;

1660 l e v e l = new HashMap<Str ing , Integer >() ;

l e v e l . put ( Quest ionStatus . TO SPECIFY, 0) ;

l e v e l . put ( Quest ionStatus .YET TO ANALYZE, 0) ;

l e v e l . put ( Quest ionStatus .REJECTED, 0) ;

l e v e l . put ( Quest ionStatus .PART AGREED, 0) ;

l e v e l . put ( Quest ionStatus .ACCEPTED, 0) ;

for ( De l ive rab l eEv idence e : l e ) {St r ing k = e . getAnswsetAnsw ( ) . getApprovat ionDel ivStatus ( ) ;

i f ( k != null && l e v e l . containsKey ( k ) )

l e v e l . put (k , l e v e l . get ( k ) + 1) ;

1670 else

System . out . p r i n t l n ( ”Chiave non trovata : ” + k ) ;

}i f ( l e v e l . get ( Quest ionStatus .ACCEPTED) > 0

&& l e v e l . get ( Quest ionStatus .REJECTED) == 0

&& l e v e l . get ( Quest ionStatus .PART AGREED) == 0)

s t a t u s = Quest ionStatus .ACCEPTED;

else i f ( l e v e l . get ( Quest ionStatus .PART AGREED) > 0)

s t a t u s = Quest ionStatus .PART AGREED;

else i f ( l e v e l . get ( Quest ionStatus .REJECTED) > 0

1680 && ( l e v e l . get ( Quest ionStatus .PART AGREED) > 0 | | l e v e l

. get ( Quest ionStatus .ACCEPTED) > 0) )

s t a t u s = Quest ionStatus .PART AGREED;

else i f ( l e v e l . get ( Quest ionStatus .REJECTED) > 0

&& l e v e l . get ( Quest ionStatus .PART AGREED) == 0

&& l e v e l . get ( Quest ionStatus .ACCEPTED) == 0)

s t a t u s = Quest ionStatus .REJECTED;

else

s t a t u s = Quest ionStatus .PART AGREED;

d . setApprova lStatus ( s t a t u s ) ;

1690 try {de l ive rab l e sMngr . s a v e D e l i v e r a b l e (d) ;

} catch ( SaveException e1 ) {e1 . pr intStackTrace ( ) ;

}}

de l ive rab l e sMngr . r e f r e s h ( a ) ;

de l ive rab l e sMngr . r e f r e s h ( r e f e r e n c e P r o j e c t ) ;

va l idUI . q u e s t i o n s L i s t ( ) ;

1700 va l idUI . que s t i onDeta i l sEv idence ( false , a ) ;

}

public Del ive rab l eEv idence ge tDe l i v e rab l eEv idence ( Evidence a ,

D e l i v e r a b l e d) {Del ive rab l eEv idence r e s = de l ive rab l e sMngr . getFromAnswsetAnsw ( a , d) ;

225

Page 244: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

i f ( r e s == null ) {r e s = new Del ive rab l eEv idence ( ) ;

r e s . s e t D e l i v e r a b l e (d) ;

r e s . setAnswsetAnsw ( a ) ;

1710 r e s . s e t Inc luded ( fa l se ) ;

try {r e s = de l ive rab l e sMngr . saveDe l ive rab l eEv idence ( r e s ) ;

} catch ( SaveException e ) {}

}return r e s ;

}

public St r ing showMultep l i c i ty ( ) {1720 int min = 0 ;

int max = re f e r enceQues t i on . getAlternat iveAnswers ( ) . s i z e ( ) ;

L i s t<RuleMul tep l i c i ty> r l s = ruleMngr

. v i e w A l l M u l t e p l i c i t y ( r e f e r enceQues t i on ) ;

for ( Ru l eMul t ep l i c i ty r : r l s ) {int qid = r . getAlternat iveAnswer ( ) . getQuest ion ( ) . getQuest ionId ( ) ;

AnswerSet as = answerSetForProject . get ( qid ) ;

for ( Evidence a l : as . getAnswsetAnsws ( ) ) {i f ( a l . getResponse ( ) . equa l s IgnoreCase ( ” yes ” )

&& a l . getAlternat iveAnswer ( ) . getAnswerId ( ) == r

1730 . getAlternat iveAnswer ( ) . getAnswerId ( ) ) {i f ( min < r . getLowebound ( ) )

min = r . getLowebound ( ) ;

i f (max > r . getUpperbound ( ) )

max = r . getUpperbound ( ) ;

}}

}return ”minimum ” + min + ” , maximum ” + max ;

}1740

public void ques t i onSe l e c t edEv idenceH i s to ry ( I n t e g e r qid ) {re f e renceAnswerSet = answerSetForProject . get ( qid ) ;

qstUI . que s t i onDeta i l sEv idenceH i s to ry ( ) ;

}

public Mpackage getReferencePackage ( ) {return r e f e r encePackage ;

}

1750 public void r e f r e s h ( AnswerSet d) {questionMngr . r e f r e s h (d) ;

}

public List<Evidence> getEvidencesForMClass ( Mclass c ) {return questionMngr . getEvidencesForMClass ( c ) ;

}

}

226

Page 245: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.2.7 Classe LoggedUser.java

package i t . uniroma2 . norge . c o n t r o l l e r ;

import i t . uniroma2 . norge . model . UserManager ;

import i t . uniroma2 . norge . model . jpa . Assignment ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

import i t . uniroma2 . norge . model . jpa . User ;

import i t . uniroma2 . norge . web . Tes iwebAppl icat ion ;

import java . i o . S e r i a l i z a b l e ;

10 import java . u t i l . ArrayList ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . NoResultException ;

import javax . s e r v l e t . http . HttpSess ion ;

import com . vaadin . t e rmina l . gwt . s e r v e r . WebApplicationContext ;

public class LoggedUser implements S e r i a l i z a b l e {

20 private stat ic f ina l long se r ia lVer s ionUID = 2975952789871318120L ;

private St r ing username ;

private boolean i sLogged ;

private TesiwebAppl icat ion appl ;

private HttpSess ion ht tpSe s s i on ;

30 private UserManager userMngr ;

private User person ;

public LoggedUser ( Tes iwebAppl icat ion te s iwebApp l i ca t i on ) {userMngr = new UserManager ( ) ;

username = ”” ;

i sLogged = fa l se ;

this . appl = te s iwebApp l i ca t i on ;

WebApplicationContext cntx = ( WebApplicationContext ) t e s iwebApp l i ca t i on

40 . getContext ( ) ;

h t tpSe s s i on = cntx . getHttpSess ion ( ) ;

}

public void s e s s i onLog in ( ) {St r ing usr = ( St r ing ) ht tpSe s s i on . ge tAt t r ibute ( ” loggedUSer ” ) ;

usr = ”” ;

try {person = userMngr . searchByUsername ( usr ) ;

i f ( person != null ) {50 appl . s e tUser ( this ) ;

i sLogged = true ;

username = usr ;

appl . buildMainLayout ( ) ;

} else {

227

Page 246: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

i sLogged = fa l se ;

appl . bui ldLoginLayout ( ) ;

}} catch ( NoResultException e ) {

i sLogged = fa l se ;

60 appl . bui ldLoginLayout ( ) ;

}}

public void formLogin ( S t r ing usr , S t r ing pwd) throws LoginException {try {

person = userMngr . searchByUsername ( usr ) ;

i f ( person != null ) {appl . s e tUser ( this ) ;

70 i sLogged = true ;

username = usr ;

appl . buildMainLayout ( ) ;

h t tpSe s s i on . s e t A t t r i b u t e ( ” loggedUSer ” , usr ) ;

} else {i sLogged = fa l se ;

throw new LoginException ( ” Login f a i l e d ! ” ) ;

}} catch ( NoResultException e ) {

i sLogged = fa l se ;

80 throw new LoginException ( ” Login f a i l e d ! ” ) ;

}}

public boolean checkEnt it lement ( S t r ing ent ) {i f ( ! i sLogged )

return fa l se ;

return true ;

}

90 public St r ing getUsername ( ) {return username ;

}

public boolean i sLogged ( ) {return i sLogged ;

}

public User getUserObj ( ) {return person ;

100 }

public boolean i sR o l e ( S t r ing r o l e ) {i f ( person == null )

return fa l se ;

for ( Assignment a : person . getAssignments ( ) )

i f ( a . getRole ( ) . getCode ( ) . equa l s ( r o l e ) )

return true ;

return fa l se ;

}110

228

Page 247: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public List<Agreement> pro j e c t sForRo l e ( S t r ing r o l e ) {ArrayList<Agreement> r i s = new ArrayList<Agreement>() ;

i f ( person == null )

return r i s ;

for ( Assignment a : person . getAssignments ( ) )

i f ( r o l e == null | | a . getRole ( ) . getCode ( ) . equa l s ( r o l e ) )

r i s . add ( a . g e tPro j e c t ( ) ) ;

return r i s ;

}120 }

D.2.8 Classe LoginException.java

package i t . uniroma2 . norge . c o n t r o l l e r ;

public class LoginException extends Exception

{

private stat ic f ina l long se r ia lVer s ionUID = 2512384720862829678L ;

public LoginException ( S t r ing msg)

{10 super (msg) ;

}

}

D.2.9 Classe OrganizationCtrl.java

package i t . uniroma2 . norge . c o n t r o l l e r ;

import i t . uniroma2 . norge . model . OrganizationsManager ;

import i t . uniroma2 . norge . model . jpa . Organizat ion ;

import i t . uniroma2 . norge . web . Organizat ionsUI ;

import i t . uniroma2 . norge . web . Tes iwebAppl icat ion ;

import java . u t i l . L i s t ;

10 import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . u i . MenuBar .Command;

import com . vaadin . u i . MenuBar . MenuItem ;

public class Organ izat ionCtr l implements Command, Property . ValueChangeListener {

private TesiwebAppl icat ion appl ;

private OrganizationsManager orgsMngr ;

20private Organizat ionsUI u i ;

229

Page 248: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public Organ izat ionCtr l ( Tes iwebAppl icat ion appl ) {this . appl = appl ;

u i = new Organizat ionsUI ( this . appl ) ;

orgsMngr = new OrganizationsManager ( ) ;

}

@Override

30 public void valueChange ( ValueChangeEvent event ) {i f ( u i . orgssTable == null ) {

System . out . p r i n t l n ( ” Tabel la non e s i s t e 2” ) ;

return ;

}}

@Override

public void menuSelected ( MenuItem se l e c t ed I t em ) {St r ing item = null ;

40 i f ( s e l e c t ed I t em != null )

item = se l e c t ed I t em . getText ( ) ;

appl . showNot i f i c a t i on ( item ) ;

appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

i f ( item != null && item . equa l s IgnoreCase ( ”add user ” ) )

u i . orgAdd ( ) ;

else

ui . o r g s L i s t A l l ( ) ;

}

50public List<Organizat ion> getLis tData ( ) {

return orgsMngr . v iewAl l ( ) ;

}

public void c r e a t e ( Organizat ion d) throws SaveException {orgsMngr . saveOrgan izat ion (d) ;

u i . o r g s L i s t A l l ( ) ;

}

60 public void update ( Organizat ion d) throws SaveException {orgsMngr . saveOrgan izat ion (d) ;

u i . o r g s L i s t A l l ( ) ;

}

public List<Organizat ion> ge tOrgan i za t i ons ( ) {return getLis tData ( ) ;

}

}

D.2.10 Classe PDFmerge.java

package i t . uniroma2 . norge . c o n t r o l l e r ;

import java . i o . Fi le InputStream ;

import java . i o . FileOutputStream ;

230

Page 249: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import java . i o . IOException ;

import java . i o . InputStream ;

import java . i o . OutputStream ;

import java . u t i l . ArrayList ;

import java . u t i l . I t e r a t o r ;

10 import java . u t i l . L i s t ;

import com . i t e x t p d f . t ex t . Document ;

import com . i t e x t p d f . t ex t . except i on s . Inva l idPdfExcept ion ;

import com . i t e x t p d f . t ex t . pdf . BaseFont ;

import com . i t e x t p d f . t ex t . pdf . PdfContentByte ;

import com . i t e x t p d f . t ex t . pdf . PdfImportedPage ;

import com . i t e x t p d f . t ex t . pdf . PdfReader ;

import com . i t e x t p d f . t ex t . pdf . PdfWriter ;

20 public class PDFmerge {public stat ic void main ( St r ing [ ] a rgs ) {

try {List<InputStream> pdfs = new ArrayList<InputStream >() ;

pdfs . add (new Fi leInputStream ( ”c :\\ pdf \\2 . pdf ” ) ) ;

pdfs . add (new Fi leInputStream ( ”c :\\ pdf \\3 . pdf ” ) ) ;

OutputStream output = new FileOutputStream ( ”c :\\ pdf \\merge . pdf ” ) ;

PDFmerge . concatPDFs ( pdfs , output , fa l se ) ;

} catch ( Exception e ) {e . pr intStackTrace ( ) ;

30 }}

public stat ic void concatPDFs ( Lis t<InputStream> streamOfPDFFiles ,

OutputStream outputStream , boolean pag inate ) {

Document document = new Document ( ) ;

try {List<InputStream> pdfs = streamOfPDFFiles ;

L i s t<PdfReader> r eade r s = new ArrayList<PdfReader >() ;

40 int to ta lPages = 0 ;

I t e r a t o r <InputStream> i teratorPDFs = pdfs . i t e r a t o r ( ) ;

while ( i teratorPDFs . hasNext ( ) ) {InputStream pdf = iteratorPDFs . next ( ) ;

try {PdfReader pdfReader = new PdfReader ( pdf ) ;

r eade r s . add ( pdfReader ) ;

to ta lPages += pdfReader . getNumberOfPages ( ) ;

System . out . p r i n t l n ( ”Merging : l e t t o un f i l e PDF” ) ;

50 } catch ( Inva l idPdfExcept ion e ) {System . out . p r i n t l n ( ”Merging : non e un f i l e PDF” ) ;

}}PdfWriter w r i t e r = PdfWriter . g e t In s tance ( document , outputStream ) ;

document . open ( ) ;

BaseFont bf = BaseFont . createFont ( BaseFont .HELVETICA,

BaseFont . CP1252 , BaseFont .NOT EMBEDDED) ;

PdfContentByte cb = w r i t e r . getDirectContent ( ) ;

60

231

Page 250: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

PdfImportedPage page ;

int currentPageNumber = 0 ;

int pageOfCurrentReaderPDF = 0 ;

I t e r a t o r <PdfReader> iteratorPDFReader = reade r s . i t e r a t o r ( ) ;

while ( iteratorPDFReader . hasNext ( ) ) {PdfReader pdfReader = iteratorPDFReader . next ( ) ;

while ( pageOfCurrentReaderPDF < pdfReader . getNumberOfPages ( ) ) {70 document . newPage ( ) ;

pageOfCurrentReaderPDF++;

currentPageNumber++;

page = w r i t e r . getImportedPage ( pdfReader ,

pageOfCurrentReaderPDF ) ;

cb . addTemplate ( page , 0 , 0) ;

i f ( pag inate ) {cb . beginText ( ) ;

cb . setFontAndSize ( bf , 9) ;

80 cb . showTextAligned ( PdfContentByte .ALIGN CENTER, ””

+ currentPageNumber + ” o f ” + tota lPages , 520 ,

5 , 0) ;

cb . endText ( ) ;

}}pageOfCurrentReaderPDF = 0 ;

}outputStream . f l u s h ( ) ;

document . c l o s e ( ) ;

90 outputStream . c l o s e ( ) ;

} catch ( Exception e ) {e . pr intStackTrace ( ) ;

} f ina l ly {i f ( document . isOpen ( ) )

document . c l o s e ( ) ;

try {i f ( outputStream != null )

outputStream . c l o s e ( ) ;

} catch ( IOException i o e ) {100 i o e . pr intStackTrace ( ) ;

}}

}}

D.2.11 Classe PDFoutput.java

package i t . uniroma2 . norge . c o n t r o l l e r ;

import i t . uniroma2 . norge . common . AnswerStatus ;

import i t . uniroma2 . norge . common . Quest ionStatus ;

import i t . uniroma2 . norge . model . QuestionnaireManager ;

import i t . uniroma2 . norge . model . jpa . AnswerSet ;

import i t . uniroma2 . norge . model . jpa . Evidence ;

232

Page 251: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import i t . uniroma2 . norge . model . jpa . De l ive rab l eContentHi s to ry ;

import i t . uniroma2 . norge . model . jpa . AnswsetHistory ;

10 import i t . uniroma2 . norge . model . jpa . Assignment ;

import i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e ;

import i t . uniroma2 . norge . model . jpa . De l ive rab l eEv idence ;

import i t . uniroma2 . norge . model . jpa . Mclass ;

import i t . uniroma2 . norge . model . jpa . Mf ie ld ;

import i t . uniroma2 . norge . model . jpa . Model ;

import i t . uniroma2 . norge . model . jpa . Mpackage ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

import i t . uniroma2 . norge . model . jpa . Question ;

import i t . uniroma2 . norge . model . jpa . Re lat ion ;

20import java . i o . ByteArrayOutputStream ;

import java . i o . IOException ;

import java . net . MalformedURLException ;

import java . t ex t . SimpleDateFormat ;

import java . u t i l . ArrayList ;

import java . u t i l . C o l l e c t i o n s ;

import java . u t i l . Comparator ;

import java . u t i l . Date ;

import java . u t i l . HashMap ;

30 import java . u t i l . LinkedHashMap ;

import java . u t i l . TreeSet ;

import com . i t e x t p d f . t ex t . BadElementException ;

import com . i t e x t p d f . t ex t . BaseColor ;

import com . i t e x t p d f . t ex t . Chapter ;

import com . i t e x t p d f . t ex t . Document ;

import com . i t e x t p d f . t ex t . DocumentException ;

import com . i t e x t p d f . t ex t . Element ;

import com . i t e x t p d f . t ex t . Font ;

40 import com . i t e x t p d f . t ex t . FontFactory ;

import com . i t e x t p d f . t ex t . Image ;

import com . i t e x t p d f . t ex t . L i s t ;

import com . i t e x t p d f . t ex t . L i s t I tem ;

import com . i t e x t p d f . t ex t . PageSize ;

import com . i t e x t p d f . t ex t . Paragraph ;

import com . i t e x t p d f . t ex t . Phrase ;

import com . i t e x t p d f . t ex t . Rectangle ;

import com . i t e x t p d f . t ex t . Sec t i on ;

import com . i t e x t p d f . t ex t . pdf . ColumnText ;

50 import com . i t e x t p d f . t ex t . pdf . PdfPCell ;

import com . i t e x t p d f . t ex t . pdf . PdfPTable ;

import com . i t e x t p d f . t ex t . pdf . PdfPageEventHelper ;

import com . i t e x t p d f . t ex t . pdf . PdfWriter ;

public class PDFoutput {

private Agreement p r o j e c t ;

private Font fontChapter ;

private Font f o n t S e c t i o n ;

60 private Font fontQuest ion ;

private Font f o n t A l t e r n a t i v e ;

private Font f on tA l t e rna t i v eDet t ;

private LinkedHashMap<Mpackage , java . u t i l . L i s t<AnswerSet>> pkgQuestions ;

233

Page 252: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private HashMap<Mpackage , byte [ ]> pkgQplot ;

private HashMap<Mpackage , byte [ ]> pkgAplot ;

private St r ing a c t u a l S i l L e v e l ;

private int pckChapterCounter ;

private HashMap<Mpackage , byte [ ]> pkgQDplot ;

private HashMap<Mpackage , byte [ ]> pkgADplot ;

70public PDFoutput ( ) {

pkgQuestions = new LinkedHashMap<Mpackage , java . u t i l . L i s t<AnswerSet>>() ;

pkgQplot = new HashMap<Mpackage , byte [ ] > ( ) ;

pkgAplot = new HashMap<Mpackage , byte [ ] > ( ) ;

pkgQDplot = new HashMap<Mpackage , byte [ ] > ( ) ;

pkgADplot = new HashMap<Mpackage , byte [ ] > ( ) ;

pckChapterCounter = 1 ;

fontChapter = FontFactory . getFont ( FontFactory .HELVETICA, 23 ,

80 Font .BOLDITALIC, new BaseColor (30 , 67 , 125) ) ;

f o n t S e c t i o n = FontFactory . getFont ( FontFactory .HELVETICA, 19 , Font .BOLD,

new BaseColor (0 , 0 , 255) ) ;

fontQuest ion = FontFactory . getFont ( FontFactory .TIMES, 15 , Font .BOLD,

new BaseColor (0 , 0 , 0) ) ;

f o n t A l t e r n a t i v e = FontFactory . getFont ( FontFactory .TIMES, 13 ,

Font . ITALIC , new BaseColor (0 , 0 , 0) ) ;

f on tA l t e rna t i v eDet t = FontFactory . getFont ( FontFactory .TIMES, 11 ,

Font .NORMAL, new BaseColor (0 , 0 , 0) ) ;

90 }

private Chapter addIntro ( ArrayList<Str ing> s u p p l i e r s ,

ArrayList<Str ing> c e r t i f i e r s ) {Paragraph someSectionText ;

S t r ing tmp sup = ”” ;

for ( S t r ing s : s u p p l i e r s )

tmp sup += s + ” , ” ;

i f ( tmp sup . l ength ( ) > 2)

tmp sup = tmp sup . su b s t r i n g (0 , tmp sup . l ength ( ) − 2) ;

100 St r ing tmp cert = ”” ;

for ( S t r ing s : c e r t i f i e r s )

tmp cert += s + ” , ” ;

i f ( tmp cert . l ength ( ) > 2)

tmp cert = tmp cert . su b s t r i n g (0 , tmp cert . l ength ( ) − 2) ;

Paragraph t i t l e = new Paragraph ( ” In t roduc t i on ” , fontChapter ) ;

Chapter chapter1 = new Chapter ( t i t l e , 1) ;

chapter1 . setNumberDepth (0 ) ;

Paragraph t i t l e 1 1 = new Paragraph ( ”Purpose” , f o n t S e c t i o n ) ;

110 Sec t i on s e c t i o n 1 1 = chapter1 . addSect ion ( t i t l e 1 1 ) ;

someSectionText = new Paragraph ( ” This chapter prov ide s g ene ra l ”

+ ” in fo rmat ion about the Agreement” ) ;

s e c t i o n 1 1 . add ( someSectionText ) ;

Paragraph t i t l e 1 2 = new Paragraph ( ”Agreement d e s c r i p t i o n ” ,

f o n t S e c t i o n ) ;

Sec t i on s e c t i o n 1 2 = chapter1 . addSect ion ( t i t l e 1 2 ) ;

L i s t l = new L i s t ( true , false , 30) ;

l . add (new List I tem ( ”Name : ” + p r o j e c t . getName ( ) ) ) ;

l . add (new List I tem ( ” Users ” ) ) ;

234

Page 253: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

120 L i s t l 2 = new L i s t ( true , false , 20) ;

l 2 . add (new List I tem ( ” Supp l i e r : ” + tmp sup ) ) ;

l 2 . add (new List I tem ( ” C e r t i f i e r : ” + tmp cert ) ) ;

l . add ( l 2 ) ;

i f ( a c t u a l S i l L e v e l != null ) {}s e c t i o n 1 2 . add ( l ) ;

return chapter1 ;

}130

private Chapter addOvera l lStat (byte [ ] i1 , byte [ ] i2 , byte [ ] i 3 )

throws BadElementException {Paragraph t i t l e = new Paragraph ( ” Overa l l s t a t i s t i c s ” , fontChapter ) ;

Chapter chapter2b = new Chapter ( t i t l e , 1) ;

chapter2b . setNumberDepth (0 ) ;

Paragraph t i t l e 1 3 = new Paragraph ( ” S t a t i s t i c s ” , f o n t S e c t i o n ) ;

Sec t i on s e c t i o n 1 3 = chapter2b . addSect ion ( t i t l e 1 3 ) ;

try {140 Image image1 = Image . g e t In s tance ( i 1 ) ;

s e c t i o n 1 3 . add ( image1 ) ;

} catch ( MalformedURLException e ) {} catch ( IOException e ) {}try {

Image image2 = Image . g e t In s tance ( i 2 ) ;

s e c t i o n 1 3 . add ( image2 ) ;

} catch ( MalformedURLException e ) {} catch ( IOException e ) {

150 }try {

Image image2 = Image . g e t In s tance ( i 3 ) ;

s e c t i o n 1 3 . add ( image2 ) ;

} catch ( MalformedURLException e ) {} catch ( IOException e ) {}return chapter2b ;

}

160private Chapter addOvera l lStatDe l iv ( ) throws BadElementException {

LinkedHashMap<Evidence , Str ing> answsets = new LinkedHashMap<Evidence ,

Str ing >() ;

LinkedHashMap<Del ive rab l e , Str ing> d e l i v s = new LinkedHashMap<Del ive rab l e ,

Str ing >() ;

PdfPTable tab leEvidence = new PdfPTable (2 ) ;

try {tab leEvidence . setWidths (new float [ ] { 0 .5 f , 3 }) ;

} catch ( DocumentException e ) {170 e . pr intStackTrace ( ) ;

}tab leEvidence . setWidthPercentage (98) ;

tab leEvidence . s e tSpac ingBe fo re (10 f ) ;

235

Page 254: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

tab leEvidence . s e tSpac ingAf t e r (10 f ) ;

PdfPCell d e f a u l t C e l l = tab leEvidence . g e t D e f a u l t C e l l ( ) ;

d e f a u l t C e l l . se tBorder ( PdfPCell .NO BORDER) ;

d e f a u l t C e l l . s e tHor i zonta lAl ignment ( Element .ALIGN LEFT) ;

d e f a u l t C e l l . s e tVer t i ca lA l i gnment ( Element .ALIGN TOP) ;

d e f a u l t C e l l . setPadding (5 ) ;

180 d e f a u l t C e l l . setBackgroundColor ( BaseColor .WHITE) ;

d e f a u l t C e l l . setBorderWidth (0 f ) ;

d e f a u l t C e l l . setBorderWidthBottom (1 f ) ;

d e f a u l t C e l l . s e tBorderColor ( BaseColor .WHITE) ;

d e f a u l t C e l l . setBorderColorBottom ( BaseColor .BLUE) ;

d e f a u l t C e l l . setUseBorderPadding ( true ) ;

Font fontQuestionRed = FontFactory . getFont ( FontFactory .TIMES, 15 ,

Font .BOLD, BaseColor .RED) ;

fontQuestionRed . s e tCo lo r ( BaseColor .RED) ;

190 Paragraph par = new Paragraph ( ” Question ” , fontQuestionRed ) ;

PdfPCell c = new PdfPCell ( par ) ;

c . setColspan (2 ) ;

c . setPadding (10) ;

par = new Paragraph ( ”Code” , fontQuestionRed ) ;

c = new PdfPCell ( par ) ;

c . setPadding (4 ) ;

c . se tHor izonta lAl ignment ( PdfPCell .ALIGN CENTER) ;

c . s e tVer t i ca lA l i gnment ( PdfPCell .ALIGN MIDDLE) ;

par = new Paragraph ( ” Evidence ” , fontQuestionRed ) ;

200 c = new PdfPCell ( par ) ;

c . setPadding (4 ) ;

c . se tHor izonta lAl ignment ( PdfPCell .ALIGN CENTER) ;

c . s e tVer t i ca lA l i gnment ( PdfPCell .ALIGN MIDDLE) ;

int i q = 0 ;

for ( Mpackage p : pkgQuestions . keySet ( ) ) {java . u t i l . L i s t<AnswerSet> tmp = pkgQuestions . get (p) ;

for ( AnswerSet tmp2 : tmp) {LinkedHashMap<Evidence , Str ing> answsetsQ = new LinkedHashMap<Evidence ,

Str ing >() ;

210 int i tems = 0 ;

boolean augmented = fa l se ;

int i e = 0 ;

for ( Evidence asa : tmp2 . getAnswsetAnsws ( ) ) {i f ( asa . getFi l lLastmod ( ) != null

&& asa . getResponse ( ) != null

&& asa . getResponse ( ) . equa l s IgnoreCase ( ” yes ” ) ) {i f ( ! augmented ) {

i q ++;

220 augmented = true ;

}i tems++;

i e ++;

St r ing code = ”Q” + i q + ” E” + i e ;

answsetsQ . put ( asa , code ) ;

answsets . put ( asa , code ) ;

}}

236

Page 255: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

i f ( i tems > 0) {230 Paragraph parQ = new Paragraph ( tmp2 . getQuest ion ( )

. getQuest ion ( ) , fontQuest ion ) ;

PdfPCell c e l l = new PdfPCell ( parQ ) ;

c e l l . setColspan (2 ) ;

c e l l . setPadding (5 ) ;

c e l l . setPaddingTop (15) ;

c e l l . s e tBorder ( PdfPCell .NO BORDER) ;

c e l l . s e tBorderColor ( BaseColor .WHITE) ;

c e l l . setBorderColorBottom ( BaseColor .BLUE) ;

tab leEvidence . addCel l ( c e l l ) ;

240 for ( Evidence asa : answsetsQ . keySet ( ) ) {St r ing code = answsetsQ . get ( asa ) ;

Paragraph pa = new Paragraph ( code , f o n t A l t e r n a t i v e ) ;

PdfPCell c l = new PdfPCell ( pa ) ;

c l . se tBorder ( PdfPCell .NO BORDER) ;

tab leEvidence . addCel l ( c l ) ;

pa = new Paragraph ( asa . getAlternat iveAnswer ( )

. getAnswer ( ) , f o n t A l t e r n a t i v e ) ;

c l = new PdfPCell ( pa ) ;

c l . se tBorder ( PdfPCell .NO BORDER) ;

250 tab leEvidence . addCel l ( c l ) ;

}}

}}

PdfPTable t a b l e D e l i v = new PdfPTable (2 ) ;

try {t a b l e D e l i v . setWidths (new float [ ] { 0 .5 f , 3 }) ;

} catch ( DocumentException e ) {260 e . pr intStackTrace ( ) ;

}t a b l e D e l i v . setWidthPercentage (98) ;

t a b l e D e l i v . s e tSpac ingBe fo re (10 f ) ;

t a b l e D e l i v . s e tSpac ingAf t e r (10 f ) ;

PdfPCell de fau l tCe l lD = t a b l e D e l i v . g e t D e f a u l t C e l l ( ) ;

de fau l tCe l lD . setBorder ( PdfPCell .NO BORDER) ;

de fau l tCe l lD . se tHor i zonta lAl ignment ( Element .ALIGN LEFT) ;

de fau l tCe l lD . s e tVer t i ca lA l i gnment ( Element .ALIGN TOP) ;

de fau l tCe l lD . setPadding (5 ) ;

270 de fau l tCe l lD . setBackgroundColor ( BaseColor .WHITE) ;

de fau l tCe l lD . setBorderWidth (0 f ) ;

de fau l tCe l lD . setBorderWidthBottom (1 f ) ;

de fau l tCe l lD . setBorderColor ( BaseColor .WHITE) ;

de fau l tCe l lD . setBorderColorBottom ( BaseColor .BLUE) ;

de fau l tCe l lD . setUseBorderPadding ( true ) ;

par = new Paragraph ( ”Code” , fontQuestionRed ) ;

c = new PdfPCell ( par ) ;

c . setPadding (10) ;

280 t a b l e D e l i v . addCel l ( c ) ;

par = new Paragraph ( ” D e l i v e r a b l e ” , fontQuestionRed ) ;

c = new PdfPCell ( par ) ;

c . setPadding (10) ;

t a b l e D e l i v . addCel l ( c ) ;

237

Page 256: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

tab leEvidence . setHeaderRows (1 ) ;

int i d = 0 ;

for ( D e l i v e r a b l e d : p r o j e c t . g e t D e l i v e r a b l e s ( ) ) {i d ++;

290 St r ing code = ”D” + i d ;

Paragraph pa = new Paragraph ( code , f o n t A l t e r n a t i v e ) ;

t a b l e D e l i v . addCel l ( pa ) ;

pa = new Paragraph (d . getName ( ) , f o n t A l t e r n a t i v e ) ;

t a b l e D e l i v . addCel l ( pa ) ;

d e l i v s . put (d , code ) ;

}

int c o l s = d e l i v s . s i z e ( ) + 1 ;

PdfPTable matrix = new PdfPTable ( c o l s ) ;

300 try {f loat [ ] w = new float [ c o l s ] ;

w [ 0 ] = 1 .5 f ;

for ( int i = 1 ; i < c o l s ; i++)

w[ i ] = 1 f ;

matrix . setWidths (w) ;

} catch ( DocumentException e ) {e . pr intStackTrace ( ) ;

}matrix . setWidthPercentage (98) ;

310 matrix . s e tSpac ingBe fo re (10 f ) ;

matrix . s e tSpac ingAf t e r (10 f ) ;

PdfPCell de fau l tCe l lM = matrix . g e t D e f a u l t C e l l ( ) ;

de fau l tCe l lM . setBorder ( Rectangle .BOX) ;

de fau l tCe l lM . setHor izonta lAl ignment ( Element .ALIGN CENTER) ;

de fau l tCe l lM . se tVer t i ca lA l i gnment ( Element .ALIGN MIDDLE) ;

de fau l tCe l lM . setPadding (5 ) ;

de fau l tCe l lM . setBackgroundColor ( BaseColor .WHITE) ;

de fau l tCe l lM . setBorderWidth (0 f ) ;

de fau l tCe l lM . setBorderWidthBottom (1 f ) ;

320 defau l tCe l lM . setBorderColor ( BaseColor .WHITE) ;

de fau l tCe l lM . setBorderColorBottom ( BaseColor .BLUE) ;

de fau l tCe l lM . setUseBorderPadding ( true ) ;

par = new Paragraph ( ”” , fontQuestionRed ) ;

c = new PdfPCell ( par ) ;

c . setPadding (10) ;

matrix . addCel l ( c ) ;

for ( D e l i v e r a b l e d : d e l i v s . keySet ( ) ) {par = new Paragraph ( d e l i v s . get (d) , fontQuestionRed ) ;

330 c = new PdfPCell ( par ) ;

c . setPadding (10) ;

matrix . addCel l ( c ) ;

}matrix . setHeaderRows (1 ) ;

boolean ch i a ro = fa l se ;

for ( Evidence asa : answsets . keySet ( ) ) {ch i a ro = ! ch i a ro ;

par = new Paragraph ( answsets . get ( asa ) , fontQuestionRed ) ;

340 c = new PdfPCell ( par ) ;

238

Page 257: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

c . se tHor izonta lAl ignment ( Element .ALIGN LEFT) ;

matrix . addCel l ( c ) ;

ArrayList<Del ive rab l e> tmp = new ArrayList<Del ive rab l e >() ;

for ( De l ive rab l eEv idence de : asa . g e tDe l i v e rab l eEv idence s ( ) ) {i f ( de . g e t D e l i v e r a b l e ( ) != null && de . ge t Inc luded ( ) != null

&& de . ge t Inc luded ( ) )

tmp . add ( de . g e t D e l i v e r a b l e ( ) ) ;

}for ( D e l i v e r a b l e d : d e l i v s . keySet ( ) ) {

350 St r ing r i s = ”” ;

i f (tmp . conta in s (d) )

r i s = ”X” ;

par = new Paragraph ( r i s , f o n t A l t e r n a t i v e ) ;

c = new PdfPCell ( par ) ;

c . se tHor izonta lAl ignment ( Element .ALIGN CENTER) ;

i f ( ch i a ro )

c . setBackgroundColor ( BaseColor .WHITE) ;

else

c . setBackgroundColor ( BaseColor .YELLOW) ;

360 matrix . addCel l ( c ) ;

}}

int colsT = answsets . va lue s ( ) . s i z e ( ) + 1 ;

PdfPTable matrixT = new PdfPTable ( colsT ) ;

try {f loat [ ] w = new float [ co lsT ] ;

w [ 0 ] = 1 .5 f ;

for ( int i = 1 ; i < colsT ; i++)

370 w[ i ] = 1 f ;

matrixT . setWidths (w) ;

} catch ( DocumentException e ) {e . pr intStackTrace ( ) ;

}matrixT . setWidthPercentage (98) ;

matrixT . s e tSpac ingBe fo re (10 f ) ;

matrixT . s e tSpac ingAf t e r (10 f ) ;

PdfPCell defaultCel lMT = matrixT . g e t D e f a u l t C e l l ( ) ;

defaultCel lMT . setBorder ( Rectangle .BOX) ;

380 defaultCel lMT . setHor izonta lAl ignment ( Element .ALIGN CENTER) ;

defaultCel lMT . se tVer t i ca lA l i gnment ( Element .ALIGN MIDDLE) ;

defaultCel lMT . setPadding (5 ) ;

defaultCel lMT . setBackgroundColor ( BaseColor .WHITE) ;

defaultCel lMT . setBorderWidth (0 f ) ;

defaultCel lMT . setBorderWidthBottom (1 f ) ;

defaultCel lMT . setBorderColor ( BaseColor .WHITE) ;

defaultCel lMT . setBorderColorBottom ( BaseColor .BLUE) ;

defaultCel lMT . setUseBorderPadding ( true ) ;

390 par = new Paragraph ( ”” , fontQuestionRed ) ;

c = new PdfPCell ( par ) ;

c . setPadding (10) ;

matrixT . addCel l ( c ) ;

for ( Evidence asa : answsets . keySet ( ) ) {Phrase par2 = new Phrase ( answsets . get ( asa ) , fontQuestionRed ) ;

c = new PdfPCell ( ) ;

239

Page 258: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

c . s e tRotat ion (90) ;

c . se tPhrase ( par2 ) ;

matrixT . addCel l ( c ) ;

400 }matrixT . setHeaderRows (1 ) ;

ch i a ro = fa l se ;

for ( D e l i v e r a b l e d : d e l i v s . keySet ( ) ) {ch i a ro = ! ch i a ro ;

par = new Paragraph ( d e l i v s . get (d) , fontQuestionRed ) ;

c = new PdfPCell ( par ) ;

c . se tHor izonta lAl ignment ( Element .ALIGN LEFT) ;

matrixT . addCel l ( c ) ;

410 ArrayList<Evidence> tmp = new ArrayList<Evidence >() ;

for ( De l ive rab l eEv idence de : d . g e tDe l i v e rab l eEv idence s ( ) ) {i f ( de . g e t D e l i v e r a b l e ( ) != null && de . ge t Inc luded ( ) != null

&& de . ge t Inc luded ( ) )

tmp . add ( de . getAnswsetAnsw ( ) ) ;

}for ( Evidence asa : answsets . keySet ( ) ) {

St r ing r i s = ”” ;

i f (tmp . conta in s ( asa ) )

r i s = ”X” ;

420 par = new Paragraph ( r i s , f o n t A l t e r n a t i v e ) ;

c = new PdfPCell ( par ) ;

c . se tHor izonta lAl ignment ( Element .ALIGN CENTER) ;

i f ( ch i a ro )

c . setBackgroundColor ( BaseColor .WHITE) ;

else

c . setBackgroundColor ( BaseColor .YELLOW) ;

matrixT . addCel l ( c ) ;

}}

430Paragraph t i t l e = new Paragraph ( ”Mapping o f ev idence s to d e l i v e r a b l e s ” ,

fontChapter ) ;

Chapter chapter2b = new Chapter ( t i t l e , 1) ;

chapter2b . setNumberDepth (0 ) ;

Paragraph t i t l e 1 1 = new Paragraph ( ”Mapping matrix ” , f o n t S e c t i o n ) ;

Sec t i on s e c t i o n 1 1 = chapter2b . addSect ion ( t i t l e 1 1 ) ;

s e c t i o n 1 1 . add ( matrix ) ;

s e c t i o n 1 1 . add ( matrixT ) ;

440Paragraph t i t l e 1 2 = new Paragraph ( ” Evidences codes ” , f o n t S e c t i o n ) ;

Sec t i on s e c t i o n 1 2 = chapter2b . addSect ion ( t i t l e 1 2 ) ;

s e c t i o n 1 2 . add ( tab leEvidence ) ;

Paragraph t i t l e 1 3 = new Paragraph ( ” D e l i v e r a b l e s codes ” , f o n t S e c t i o n ) ;

Sec t i on s e c t i o n 1 3 = chapter2b . addSect ion ( t i t l e 1 3 ) ;

s e c t i o n 1 3 . add ( t a b l e D e l i v ) ;

return chapter2b ;

450 }

private Element addChapterPackage ( Mpackage p , boolean agreement ,

240

Page 259: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

boolean mapping , boolean graphs , boolean i sContext ,

boolean historyE , boolean historyD ) throws BadElementException {byte [ ] i 1 = pkgQplot . get (p) ;

byte [ ] i 2 = pkgAplot . get (p) ;

byte [ ] i 3 = pkgADplot . get (p) ;

java . u t i l . L i s t<AnswerSet> answsets = pkgQuestions . get (p) ;

C o l l e c t i o n s . s o r t ( answsets , new AnswerSetComparator ( ) ) ;

460 Paragraph c h 2 t i t l e = new Paragraph ( ”Chapter ” + ( pckChapterCounter++)

+ ” : Package ” + p . getName ( ) , fontChapter ) ;

Chapter chapter2 = new Chapter ( c h 2 t i t l e , 1) ;

chapter2 . setNumberDepth (0 ) ;

i f ( graphs ) {Paragraph t i t l e 1 3 = new Paragraph ( ” S t a t i s t i c s ” , f o n t S e c t i o n ) ;

Sec t i on s e c t i o n 1 3 = chapter2 . addSect ion ( t i t l e 1 3 ) ;

try {Image image1 = Image . g e t In s tance ( i 1 ) ;

s e c t i o n 1 3 . add ( image1 ) ;

470 } catch ( MalformedURLException e ) {} catch ( IOException e ) {}try {

Image image2 = Image . g e t In s tance ( i 2 ) ;

s e c t i o n 1 3 . add ( image2 ) ;

} catch ( MalformedURLException e ) {} catch ( IOException e ) {}i f ( ! i sContext )

480 try {Image image2 = Image . g e t In s tance ( i 3 ) ;

s e c t i o n 1 3 . add ( image2 ) ;

} catch ( MalformedURLException e ) {} catch ( IOException e ) {}

}Paragraph t i t l e 2 2 = new Paragraph ( ”Agreement on ev idence ” ,

f o n t S e c t i o n ) ;

Sec t i on s e c t i o n 2 2 = chapter2 . addSect ion ( t i t l e 2 2 ) ;

490 L i s t l q u e s t i o n = new L i s t ( true , false , 20) ;

S t r ing s ;

SimpleDateFormat fo rmatte r = new SimpleDateFormat ( ”dd−MMM−yy h :mm a” ) ;

for ( AnswerSet as : answsets )

i f ( as . getQuest ion ( ) . g e tRe la t i on ( ) == null ) {L i s t l q u e s t i o n d e t = new L i s t ( true , false , 20) ;

S t r ing s1 = as . getApprovat ionStatusFina l ( ) ;

i f ( s1 == null )

s1 = Quest ionStatus .TO SPECIFY;

St r ing s2 = as . getDe l ivApprovat ionStatus ( ) ;

500 i f ( s2 == null )

s2 = Quest ionStatus .TO SPECIFY;

i f ( ! i sContext && ( agreement | | mapping ) ) {St r ing sX = Quest ionStatus . min ( s1 , s2 ) ;

i f ( sX == null )

sX = Quest ionStatus .TO SPECIFY;

l q u e s t i o n d e t . add (new List I tem (new Paragraph (

” Fina l s t a t u s : ” + sX , f on tA l t e rna t i v eDet t ) ) ) ;

}

241

Page 260: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

i f ( ! i sContext && agreement )

510 l q u e s t i o n d e t . add (new List I tem (new Paragraph (

” Evidence s t a t u s : ” + s1 , f on tA l t e rna t i v eDet t ) ) ) ;

i f ( ! i sContext && mapping )

l q u e s t i o n d e t

. add (new List I tem (new Paragraph (

” D e l i v e r a b l e s s t a t u s : ” + s2 ,

f on tA l t e rna t i v eDet t ) ) ) ;

L i s t l answer = new L i s t ( false , true , 20) ;

L i s t l a n s w e r d e t = new L i s t ( false , false , 20) ;

i f ( as . getQuest ion ( ) . getOpenQuestion ( ) != null

520 && as . getQuest ion ( ) . getOpenQuestion ( ) . toLowerCase ( )

. equa l s ( ” yes ” ) ) {i f ( as . getFi l lLastmod ( ) != null ) {

i f ( as . getApprovLastmod ( ) != null ) {s = formatte r . format ( as . getApprovLastmod ( ) ) ;

} else

s = ” undef ined ” ;

i f ( as . getApprovat ionStatus ( ) . s tartsWith (

Quest ionStatus .ACCEPTED) )

s = ”Agreed ( ” + s + ” ) ” ;

530 else i f ( as . getApprovat ionStatus ( ) . s tartsWith (

Quest ionStatus .PART AGREED) )

s = ” P a r t i a l l y agreed ( ” + s + ” ) ” ;

else i f ( as . getApprovat ionStatus ( ) . s tartsWith (

Quest ionStatus .REJECTED) )

s = ” Disagreed ( ” + s + ” ) ” ;

else

s = ”Not yet v e r i f i e d ” ;

i f ( ! i sContext && agreement )

l a n s w e r d e t . add (new List I tem (new Paragraph (

540 ”Agreement on ev idence : ” + s ,

f on tA l t e rna t i v eDet t ) ) ) ;

L i s t I tem item = new List I tem ( ) ;

item . add (new Paragraph ( as . getOpenAnswer ( ) ,

f o n t A l t e r n a t i v e ) ) ;

item . add ( l a n s w e r d e t ) ;

l answer . add ( item ) ;

L i s t I tem itemo = new List I tem ( ) ;

itemo . add (new Paragraph ( ”Open response : ” ,

f o n t A l t e r n a t i v e ) ) ;

550 itemo . add ( l answer ) ;

i f ( agreement )

l q u e s t i o n d e t . add ( itemo ) ;

} else {i f ( agreement )

l a n s w e r d e t . add (new List I tem (new Paragraph (

”Not proposed ” , f on tA l t e rna t i v eDet t ) ) ) ;

}}int i tems = 0 ;

560 for ( Evidence asa : as . getAnswsetAnsws ( ) ) {l a n s w e r d e t = new L i s t ( false , false , 20) ;

i f ( asa . getFi l lLastmod ( ) != null

&& asa . getResponse ( ) != null

&& asa . getResponse ( ) . equa l s IgnoreCase ( ” yes ” ) ) {

242

Page 261: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

s = formatte r . format ( asa . getFi l lLastmod ( ) ) ;

i f ( agreement )

l a n s w e r d e t . add (new List I tem (

new Paragraph ( ”Proposed ( ” + s + ” ) ” ,

f on tA l t e rna t i v eDet t ) ) ) ;

570 i f ( asa . getApprovLastmod ( ) != null ) {s = formatte r . format ( asa . getApprovLastmod ( ) ) ;

} else

s = ” undef ined ” ;

i f ( asa . getApprovat ionStatus ( ) . s tartsWith (

AnswerStatus .ACCEPTED) )

s = ”Agreed ( ” + s + ” ) ” ;

else i f ( asa . getApprovat ionStatus ( ) . s tartsWith (

AnswerStatus .PART AGREED) )

s = ” Disageed ( ” + s + ” ) ” ;

580 else i f ( asa . getApprovat ionStatus ( ) . s tartsWith (

AnswerStatus .REJECTED) )

s = ” Disageed ( ” + s + ” ) ” ;

else

s = Quest ionStatus .YET TO ANALYZE;

St r ing AgreementOnEvidence = s ;

i f ( asa . getApprovat ionDel ivStatus ( ) . s tartsWith (

AnswerStatus .ACCEPTED) )

s = ”Agreed” ;

else i f ( asa . getApprovat ionDel ivStatus ( ) . s tartsWith (

590 AnswerStatus .PART AGREED) )

s = ” Disageed ” ;

else i f ( asa . getApprovat ionDel ivStatus ( ) . s tartsWith (

AnswerStatus .REJECTED) )

s = ” Disageed ” ;

else

s = Quest ionStatus .YET TO ANALYZE;

L i s t l d e l i v = new L i s t ( false , false , 20) ;

L i s t l d e l i v d e t = new L i s t ( false , false , 20) ;

boolean j = fa l se ;

600 for ( De l ive rab l eEv idence d : asa

. g e tDe l i v e rab l eEv idence s ( ) ) {i f (d . ge t Inc luded ( ) != null && d . get Inc luded ( ) ) {

j = true ;

S t r ing s11 = ”” ;

i f (d . g e t A d d i t i o n a l I n f o ( ) != null

&& d . g e t A d d i t i o n a l I n f o ( ) . l ength ( ) > 0)

s11 = ” ( ” + d . g e t A d d i t i o n a l I n f o ( ) + ” ) ” ;

l d e l i v d e t . add (new List I tem (new Paragraph (d

. g e t D e l i v e r a b l e ( ) . getName ( )

610 + s11 , f on tA l t e rna t i v eDet t ) ) ) ;

}}St r ing AgreementOnDeliverables = s ;

i f ( AgreementOnDeliverables == Quest ionStatus .TO SPECIFY)

AgreementOnDeliverables = Quest ionStatus .YET TO ANALYZE;

i f ( AgreementOnDeliverables == null )

AgreementOnDeliverables = Quest ionStatus .TO SPECIFY;

Li s t I tem item = new List I tem ( ) ;

item . add (new Paragraph ( ””

620 + asa . getAlternat iveAnswer ( ) . getAnswer ( ) ,

243

Page 262: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

f o n t A l t e r n a t i v e ) ) ;

item . add ( l a n s w e r d e t ) ;

i f ( ! i sContext && ( agreement | | mapping ) )

l a n s w e r d e t . add (new List I tem (new Paragraph (

” Fina l agreement : ”

+ AnswerStatus . min (

AgreementOnEvidence ,

AgreementOnDeliverables ) ,

f on tA l t e rna t i v eDet t ) ) ) ;

630 i f ( ! i sContext && agreement )

l a n s w e r d e t . add (new List I tem (new Paragraph (

”Agreement on ev idence : ”

+ AgreementOnEvidence ,

f on tA l t e rna t i v eDet t ) ) ) ;

i f ( ! i sContext && mapping ) {l a n s w e r d e t . add (new List I tem (new Paragraph (

”Agreement on d e l i v e r a b l e s : ”

+ AgreementOnDeliverables ,

f on tA l t e rna t i v eDet t ) ) ) ;

640 i f ( j ) {List I tem itemd = new List I tem ( ) ;

itemd . add (new Paragraph (

”Mapped in f o l l o w i n g d e l i v e r a b l e s : ” ,

f on tA l t e rna t i v eDet t ) ) ;

itemd . add ( l d e l i v d e t ) ;

l d e l i v . add ( itemd ) ;

}}i f ( historyD

650 && asa . getAnswsetAnswDel ivHistor ies ( ) . s i z e ( ) > 0) {L i s t l d e l i v h i s t = new L i s t ( false , false , 20) ;

for ( De l ive rab l eContentHi s to ry dh : asa

. getAnswsetAnswDel ivHistor ies ( ) ) {St r ing h = dh . toLongStr ing ( ) ;

l d e l i v h i s t . add (new List I tem (new Paragraph (h ,

f on tA l t e rna t i v eDet t ) ) ) ;

}List I tem itemd = new List I tem ( ) ;

itemd . add (new Paragraph ( ” His tory o f d e l i v e r a b l e s : ” ,

660 f on tA l t e rna t i v eDet t ) ) ;

itemd . add ( l d e l i v h i s t ) ;

l d e l i v . add ( itemd ) ;

}item . add ( l d e l i v ) ;

l answer . add ( item ) ;

i tems++;

} else {i f ( mapping )

670 l a n s w e r d e t . add (new List I tem (new Paragraph (

”Not proposed ” , f on tA l t e rna t i v eDet t ) ) ) ;

}}i f ( i tems > 0) {

l q u e s t i o n . add (new List I tem (new Paragraph ( ””

+ as . getQuest ion ( ) . getQuest ion ( ) , fontQuest ion ) ) ) ;

244

Page 263: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

List I tem item = new List I tem ( ) ;

item . add (new Paragraph ( ”Proposed a l t e r n a t i v e s : ” ,

f o n t A l t e r n a t i v e ) ) ;

680 item . add ( l answer ) ;

l q u e s t i o n d e t . add ( item ) ;

l q u e s t i o n . add ( l q u e s t i o n d e t ) ;

}i f ( h i s toryE && as . ge tAnswse tHi s to r i e s ( ) . s i z e ( ) > 0) {

L i s t l d e l i v h i s t = new L i s t ( false , false , 20) ;

for ( AnswsetHistory dh : as . g e tAnswse tH i s to r i e s ( ) ) {St r ing h = dh . toLongStr ing ( ) ;

l d e l i v h i s t . add (new List I tem (new Paragraph (h ,

f on tA l t e rna t i v eDet t ) ) ) ;

690 }List I tem itemd = new List I tem ( ) ;

itemd . add (new Paragraph ( ” His tory o f ev idence : ” ,

f on tA l t e rna t i v eDet t ) ) ;

itemd . add ( l d e l i v h i s t ) ;

l q u e s t i o n d e t . add ( itemd ) ;

}TreeSet<Relat ion> r e l s = new TreeSet<Relat ion >() ;

Mclass oc = as . getQuest ion ( ) . getMclass ( ) ;

Model m = oc . getMpackage ( ) . getModel ( ) ;

700 for ( Mpackage pp : m. getMpackages ( ) )

for ( Mclass c : pp . ge tMc las se s ( ) )

for ( Mf ie ld f : c . g e t F i e l d s ( ) ) {for ( Re lat ion r : f . g e tRe la t i onsSource ( ) )

i f ( ( r . ge tMf i e ldSource ( ) != null && r

. getMf i e ldSource ( ) . getOwnerClass ( ) == oc )

| | ( r . getMf ie ldTarget ( ) != null && r

. getMf ie ldTarget ( )

. getOwnerClass ( ) == oc ) )

r e l s . add ( r ) ;

710 for ( Re lat ion r : f . g e tRe la t i onsTarge t ( ) )

i f ( ( r . ge tMf i e ldSource ( ) != null && r

. getMf i e ldSource ( ) . getOwnerClass ( ) == oc )

| | ( r . getMf ie ldTarget ( ) != null && r

. getMf ie ldTarget ( )

. getOwnerClass ( ) == oc ) )

r e l s . add ( r ) ;

}i f ( r e l s . s i z e ( ) > 0) {

L i s t l r e l a t i o n s d e t = new L i s t ( false , false , 20) ;

720 QuestionnaireManager qmngr = new QuestionnaireManager ( ) ;

for ( Re lat ion r : r e l s ) {for ( Question q : r . getQuest ions ( ) ) {

AnswerSet a = qmngr

. getAnswerSet (q , as . g e tPro j e c t ( ) ) ;

i f ( a != null && a . getOpenAnswer ( ) != null

&& ! a . getOpenAnswer ( ) . equa l s ( ”” ) ) {List I tem itemd = new List I tem ( ) ;

S t r ing tmp = a . getQuest ion ( ) . getQuest ion ( ) ;

tmp = tmp . r e p l a c e (

730 ”You should s p e c i f y the l i n k ” ,

” Re lat ion ” ) ;

itemd . add (new Paragraph (tmp + ” : \n”

245

Page 264: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

+ a . getOpenAnswer ( ) ,

f on tA l t e rna t i v eDet t ) ) ;

l r e l a t i o n s d e t . add ( itemd ) ;

}}

}List I tem l r e l a t i o n s = new List I tem ( ) ;

740 l r e l a t i o n s . add (new Paragraph (

” S p e c i f i c a t i o n o f r e l a t i o n s between concepts ” ,

f on tA l t e rna t i v eDet t ) ) ;

l r e l a t i o n s . add ( l r e l a t i o n s d e t ) ;

l q u e s t i o n d e t . add ( l r e l a t i o n s ) ;

}}

s e c t i o n 2 2 . add ( l q u e s t i o n ) ;

return chapter2 ;

}750

private St r ing de f in i t i onOfContex t = ” D e f i n i t i o n o f C o n t e x t ” ;

public byte [ ] agreement ( Agreement prj , byte [ ] i1 , byte [ ] i2 , byte [ ] i3 ,

byte [ ] i4 , boolean parte1 , boolean agreement , boolean mapping ,

boolean parte2 , boolean graphs , boolean historyE , boolean historyD ,

boolean context ) throws DocumentException {p r o j e c t = pr j ;

ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ;

760 Document document = new Document ( PageSize . A4 , 75 , 50 , 75 , 50) ;

document . open ( ) ;

PdfWriter w r i t e r = PdfWriter . g e t In s tance ( document , baos ) ;

w r i t e r . se tBoxSize ( ” a r t ” , new Rectangle (36 , 54 , 559 , 788) ) ;

ArrayList<Str ing> s u p p l i e r s = new ArrayList<Str ing >() ;

ArrayList<Str ing> c e r t i f i e r s = new ArrayList<Str ing >() ;

for ( Assignment a : p r o j e c t . getAssignments ( ) ) {i f ( a . getRole ( ) . getCode ( ) . equa l s ( ” s u p p l i e r ” ) ) {

770 s u p p l i e r s . add ( a . getUser ( ) . getName ( ) ) ;

} else i f ( a . getRole ( ) . getCode ( ) . equa l s ( ” c e r t i f i e r ” ) ) {c e r t i f i e r s . add ( a . getUser ( ) . getName ( ) ) ;

}}

HeaderFooter event = new HeaderFooter ( ) ;

w r i t e r . setPageEvent ( event ) ;

document . open ( ) ;

780 document . add ( addIntro ( s u p p l i e r s , c e r t i f i e r s ) ) ;

i f ( parte1 ) {i f ( graphs )

i f ( pkgQuestions . keySet ( ) . s i z e ( ) > 1)

document . add ( addOvera l lStat ( i1 , i2 , i 3 ) ) ;

i f ( context )

for ( Mpackage p : pkgQuestions . keySet ( ) ) {i f (p . getCanonicalName ( ) . conta in s ( de f in i t i onOfContex t ) )

document . add ( addChapterPackage (p , agreement , mapping ,

246

Page 265: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

graphs , true , h istoryE , historyD ) ) ;

790 }for ( Mpackage p : pkgQuestions . keySet ( ) ) {

i f ( ! p . getCanonicalName ( ) . conta in s ( de f in i t i onOfContext ) )

document . add ( addChapterPackage (p , agreement , mapping ,

graphs , false , h istoryE , historyD ) ) ;

}}i f ( parte2 ) {

i f ( pkgQuestions . keySet ( ) . s i z e ( ) > 1) {document . add ( addOvera l lStatDe l iv ( ) ) ;

800 }}document . c l o s e ( ) ;

return baos . toByteArray ( ) ;

}

protected class AnswerSetComparator implements Comparator<AnswerSet> {@Override

public int compare ( AnswerSet o1 , AnswerSet o2 ) {i f ( o1 instanceof AnswerSet && o2 instanceof AnswerSet ) {

810 i f ( o1 . getQuest ion ( ) . getQuest ionId ( ) < o2 . getQuest ion ( )

. getQuest ionId ( ) )

return −1;

else

return 1 ;

}return 0 ;

}

}820

stat ic class HeaderFooter extends PdfPageEventHelper {

private SimpleDateFormat fo rmatte r ;

private Date date ;

public void onEndPage ( PdfWriter wr i t e r , Document document ) {Rectangle r e c t = w r i t e r . getBoxSize ( ” a r t ” ) ;

switch ( w r i t e r . getPageNumber ( ) % 2) {case 0 :

830 St r ing d = formatte r . format ( date ) ;

ColumnText . showTextAligned ( w r i t e r . getDirectContent ( ) ,

Element .ALIGN RIGHT, new Phrase (d) , r e c t . getRight ( ) ,

r e c t . getTop ( ) , 0) ;

break ;

case 1 :

i f ( w r i t e r . getPageNumber ( ) == 1) {ColumnText . showTextAligned ( w r i t e r . getDirectContent ( ) ,

Element .ALIGN LEFT, new Phrase ( ” C o n f i d e n t i a l ” ) ,

r e c t . g e tLe f t ( ) , r e c t . getTop ( ) , 0) ;

840 } else {ColumnText . showTextAligned ( w r i t e r . getDirectContent ( ) ,

Element .ALIGN LEFT, new Phrase (

”Agreement on ev idence ” ) , r e c t . g e tLe f t ( ) ,

r e c t . getTop ( ) , 0) ;

247

Page 266: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}break ;

}ColumnText . showTextAligned ( w r i t e r . getDirectContent ( ) ,

Element .ALIGN CENTER, new Phrase ( S t r ing . format ( ”Page %d” ,

850 w r i t e r . getPageNumber ( ) ) ) , ( r e c t . g e tLe f t ( ) + r e c t

. getRight ( ) ) / 2 , r e c t . getBottom ( ) − 18 , 0) ;

}

public HeaderFooter ( ) {super ( ) ;

f o rmatte r = new SimpleDateFormat ( ”E, dd MMM yyyy HH:mm: s s Z” ) ;

date = new Date ( ) ;

}}

860public void addPackage ( Mpackage pkg , java . u t i l . L i s t<AnswerSet> l i s t ,

byte [ ] q , byte [ ] a , byte [ ] qd , byte [ ] ad ) {pkgQuestions . put ( pkg , l i s t ) ;

pkgQplot . put ( pkg , q ) ;

pkgAplot . put ( pkg , a ) ;

pkgQDplot . put ( pkg , qd ) ;

pkgADplot . put ( pkg , ad ) ;

}

870 public void s e t S i l Q u e s t i o n ( St r ing a c t u a l S i l L e v e l ) {this . a c t u a l S i l L e v e l = a c t u a l S i l L e v e l ;

}}

D.2.12 Classe QuestionnairesCtrl.java

package i t . uniroma2 . norge . c o n t r o l l e r ;

import i t . uniroma2 . norge . model . PackageManager ;

import i t . uniroma2 . norge . model . QuestionnaireManager ;

import i t . uniroma2 . norge . model . RuleManager ;

import i t . uniroma2 . norge . model . jpa . Alternat iveAnswer ;

import i t . uniroma2 . norge . model . jpa . Mclass ;

import i t . uniroma2 . norge . model . jpa . Mpackage ;

import i t . uniroma2 . norge . model . jpa . Question ;

10 import i t . uniroma2 . norge . model . jpa . Quest ionna i re ;

import i t . uniroma2 . norge . model . jpa . RuleExclus ion ;

import i t . uniroma2 . norge . model . jpa . Ru l eMul t ep l i c i ty ;

import i t . uniroma2 . norge . web . PieChart ;

import i t . uniroma2 . norge . web . Quest ionnaireUI ;

import i t . uniroma2 . norge . web . Tes iwebAppl icat ion ;

import java . awt . Color ;

import java . awt . image . BufferedImage ;

import java . i o . ByteArrayInputStream ;

20 import java . i o . ByteArrayOutputStream ;

import java . i o . IOException ;

import java . i o . InputStream ;

248

Page 267: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import java . u t i l . ArrayList ;

import java . u t i l . HashMap ;

import java . u t i l . LinkedHashMap ;

import java . u t i l . L i s t ;

import java . u t i l . TreeSet ;

import javax . imageio . ImageIO ;

30import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . t e rmina l . StreamResource ;

import com . vaadin . u i . MenuBar .Command;

import com . vaadin . u i . MenuBar . MenuItem ;

public class Ques t i onna i r e sCt r l implements Command, Property . ValueChangeListener {

public stat ic f ina l St r ing Si lQuest ionCode = ” SILquest ion ” ;

40private TesiwebAppl icat ion appl ;

private QuestionnaireManager questionMngr ;

private Question r e f e r enceQues t i on ;

private Quest ionna i re r e f e r e n c e Q u e s t i o n n a i r e ;

private Quest ionnaireUI qstUI ;

private RuleManager ruleMngr ;

50private RuleExclus ion r e f e r enceRu l eExc lu s i on ;

private RuleMul t ep l i c i ty r e f e r e n c e R u l e M u l t e p l i c i t y ;

private Alternat iveAnswer re ferenceAnswer ;

private StreamResource resoursePiePackage ;

private StreamResource r e s o u r s e P i e C l a s s ;

60private Mpackage cntxtPackage = null ;

public Ques t i onna i r e sCt r l ( f ina l TesiwebAppl icat ion appl ) {questionMngr = new QuestionnaireManager ( ) ;

ruleMngr = new RuleManager ( ) ;

this . appl = appl ;

qstUI = new Quest ionnaireUI ( appl ) ;

}

70 public List<Quest ionnaire> getL i s tDataQues t ionna i r e ( ) {return questionMngr . v iewAl l ( ) ;

}

public List<Question> getLis tData ( ) {return r e f e r e n c e Q u e s t i o n n a i r e . getQuest ions ( ) ;

}

public void menuSelected ( MenuItem se l e c t ed I t em ) {

249

Page 268: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

St r ing item = null ;

80 i f ( s e l e c t ed I t em != null )

item = se l e c t ed I t em . getText ( ) ;

appl . showNot i f i c a t i on ( item ) ;

appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

i f ( item != null && item . equa l s IgnoreCase ( ”Add q u e s t i o n n a i r e ” ) )

qstUI . quest ionnaireAdd ( ) ;

else

qstUI . q u e s t i o n n a i r e L i s t ( ) ;

}

90 @Override

public void valueChange ( ValueChangeEvent event ) {qstUI . q u e s t i o n n a i r e D e t a i l s ( ) ;

}

public void viewAl l ( Quest ionna i re qst ) {r e f e r e n c e Q u e s t i o n n a i r e = qst ;

in i tCntxtPackage ( ) ;

qstUI . q u e s t i o n s L i s t ( ) ;

}100

public void addQuestion ( ) {qstUI . questionAdd ( ) ;

}

public void c r e a t e ( Quest ionna i re quest ) throws SaveException {questionMngr . saveQuest ionna i r e ( quest ) ;

qstUI . q u e s t i o n n a i r e L i s t ( ) ;

}

110 public void c r e a t e ( Question quest ) throws SaveException {i f ( quest . getS i lDependent ( ) == null )

quest . s e tS i lDependent ( fa l se ) ;

else i f ( quest . getS i lDependent ( ) )

checkS i lQues t i on ( ) ;

i f ( quest . g e tContex tDe f in i t i on ( ) ) {i f ( cntxtPackage == null )

in i tCntxtPackage ( ) ;

quest . setMpackage ( cntxtPackage ) ;

Mclass m = null ;

120 i f ( cntxtPackage . ge tMc las se s ( ) != null

&& cntxtPackage . ge tMc las se s ( ) . s i z e ( ) > 0)

m = cntxtPackage . ge tMc las se s ( ) . get (0 ) ;

quest . s e tMclas s (m) ;

}quest . s e tQue s t i onna i r e ( r e f e r e n c e Q u e s t i o n n a i r e ) ;

questionMngr . saveQuest ion ( quest ) ;

questionMngr . r e f r e s h ( r e f e r e n c e Q u e s t i o n n a i r e ) ;

qstUI . q u e s t i o n s L i s t ( ) ;

}130

private void in i tCntxtPackage ( ) {St r ing cntxt = ”#//D e f i n i t i o n o f C o n t e x t ” ;

PackageManager pkgMngr = new PackageManager ( ) ;

L i s t<Mpackage> r e s = pkgMngr . getByCanonicalName ( cntxt ,

250

Page 269: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

r e f e r e n c e Q u e s t i o n n a i r e . getModel ( ) ) ;

i f ( r e s == null | | r e s . s i z e ( ) <= 0) {} else {

cntxtPackage = r e s . get (0 ) ;

}140 }

public void update ( Quest ionna i re quest ) throws SaveException {questionMngr . saveQuest ionna i r e ( quest ) ;

}

public void update ( Question quest ) throws SaveException {i f ( quest . getS i lDependent ( ) != null && quest . getS i lDependent ( ) == true )

checkS i lQues t i on ( ) ;

i f ( quest . g e tContex tDe f in i t i on ( ) ) {150 i f ( cntxtPackage == null )

in i tCntxtPackage ( ) ;

quest . setMpackage ( cntxtPackage ) ;

Mclass m = null ;

i f ( cntxtPackage . ge tMc las se s ( ) != null

&& cntxtPackage . ge tMc las se s ( ) . s i z e ( ) > 0)

m = cntxtPackage . ge tMc las se s ( ) . get (0 ) ;

quest . s e tMclas s (m) ;

}questionMngr . saveQuest ion ( quest ) ;

160 qstUI . q u e s t i o n s L i s t ( ) ;

}

public void update ( Alternat iveAnswer ans ) throws SaveException {questionMngr . saveAnswer ( ans ) ;

questionMngr . r e f r e s h ( ans ) ;

i f ( ans . g e tFathe rA l t e rna t ive ( ) != null )

questionMngr . r e f r e s h ( ans . g e tFathe rA l t e rna t ive ( ) ) ;

questionMngr . r e f r e s h ( ans . getQuest ion ( ) ) ;

qstUI . q u e s t i o n D e t a i l s ( ) ;

170 }

public List<AlternativeAnswer> getAnswerListData ( ) {questionMngr . r e f r e s h ( r e f e r e n c e Q u e s t i o n n a i r e ) ;

questionMngr . r e f r e s h ( r e f e r enceQues t i on ) ;

return r e f e r enceQues t i on . getAlternat iveAnswers ( ) ;

}

public List<AlternativeAnswer> getAnswerLis tDataFirs tLeve l ( ) {questionMngr . r e f r e s h ( r e f e r enceQues t i on ) ;

180 List<AlternativeAnswer> r e s = new ArrayList<AlternativeAnswer >() ;

for ( Alternat iveAnswer a : r e f e r enceQue s t i on . getAlternat iveAnswers ( ) )

i f ( a . g e tFathe rA l t e rna t iv e ( ) == null )

r e s . add ( a ) ;

return r e s ;

}

public void addAnswer ( ) {qstUI . answerAdd ( ) ;

}190

251

Page 270: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void createAnswer ( Alternat iveAnswer ans ) throws SaveException {ans . se tQuest ion ( r e f e r enceQues t i on ) ;

i f ( ans . getTrueSi lMinLeve l ( ) == null )

ans . s e tS i lMinLeve l ( Alternat iveAnswer . MaxSilLevel ) ;

questionMngr . saveAnswer ( ans ) ;

i f ( ans . ge tS i lMinLeve l ( ) < Alternat iveAnswer . MaxSilLevel )

c r e a t e S i l E x c l u s i o n R u l e s ( ans ) ;

qstUI . q u e s t i o n D e t a i l s ( ) ;

}200

private void c r e a t e S i l E x c l u s i o n R u l e s ( Alternat iveAnswer ans )

throws SaveException {HashMap<Integer , AlternativeAnswer> x = new HashMap<Integer ,

AlternativeAnswer >() ;

RuleExclus ion r ;

for ( Alternat iveAnswer aa : r e f e r e n c e Q u e s t i o n n a i r e . g e tS i lQue s t i on ( )

. getAlternat iveAnswers ( ) ) {i f ( aa . getAnswerCode ( ) != null && aa . getAnswerCode ( ) . l ength ( ) == 4) {

I n t e g e r i = I n t e g e r . pa r s e In t ( aa . getAnswerCode ( ) . s ub s t r i ng (3 ) ) ;

x . put ( i , aa ) ;

210 }}for ( int i = 1 ; i < Alternat iveAnswer . MaxSilLevel ; i++) {

r = null ;

i f ( x . containsKey ( i ) )

r = ruleMngr . s earch ( ans , x . get ( i ) ) ;

i f ( r == null && ans . ge tS i lMinLeve l ( ) > i && x . containsKey ( i ) ) {r = new RuleExclus ion ( ) ;

r . s e tAlternat iveAnswerSource ( x . get ( i ) ) ;

r . se tAlternat iveAnswerTarget ( ans ) ;

220 r . s e t S i l ( true ) ;

ruleMngr . saveRule ( r ) ;

} else i f ( r != null && ans . ge tS i lMinLeve l ( ) <= i ) {ruleMngr . d e l e t e ( r ) ;

}}

}

private class Quest ionSe l ec ted implements Property . ValueChangeListener {

230 @Override

public void valueChange ( ValueChangeEvent event ) {r e f e r enceQues t i on = ( Question ) qstUI . ques t ionsTab le . getValue ( ) ;

qstUI . q u e s t i o n D e t a i l s ( ) ;

}}

private class AnswerSelected implements Property . ValueChangeListener {

@Override

240 public void valueChange ( ValueChangeEvent event ) {Alternat iveAnswer tmp = ( Alternat iveAnswer ) qstUI . answersTable

. getValue ( ) ;

i f (tmp == null )

return ;

r e ferenceAnswer = questionMngr . getAltAnswer (tmp . getAnswerId ( ) ) ;

252

Page 271: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

qstUI . answerDeta i l s ( ) ;

}}

250 public Quest ionSe l ec ted ge tQues t i onSe l e c t ed ( ) {return new Quest ionSe l ec ted ( ) ;

}

public AnswerSelected getAnswerSe lected ( ) {return new AnswerSelected ( ) ;

}

public void v iewAl lExc lus ion ( Alternat iveAnswer ans ) {260 re ferenceAnswer = ans ;

qstUI . e x c l u s i o n L i s t ( ) ;

}

public void v i e w A l l M u l t e p l i c i t y ( Alternat iveAnswer ans ) {re ferenceAnswer = ans ;

qstUI . m u l t e p l i c i t y L i s t ( ) ;

}

public void addExclusionRule ( ) {270 qstUI . exclusionAdd ( ) ;

}

public void addMultep l i c i tyRule ( ) {qstUI . multep l i c i tyAdd ( ) ;

}

public void c r e a t e ( RuleExclus ion r ) throws SaveException {r . s e tAlternat iveAnswerSource ( re ferenceAnswer ) ;

ruleMngr . saveRule ( r ) ;

280 qstUI . e x c l u s i o n L i s t ( ) ;

}

public void c r e a t e ( Ru l eMul t ep l i c i ty r ) throws SaveException {r . s e tAl te rnat iveAnswer ( re ferenceAnswer ) ;

ruleMngr . saveRule ( r ) ;

qstUI . m u l t e p l i c i t y L i s t ( ) ;

}

public void update ( RuleExclus ion r ) throws SaveException {290 ruleMngr . saveRule ( r ) ;

}

public void update ( Ru l eMul t ep l i c i ty r ) throws SaveException {ruleMngr . saveRule ( r ) ;

}

public List<RuleExclusion> getRulesExcluListData ( ) {questionMngr . r e f r e s h ( re ferenceAnswer ) ;

return re ferenceAnswer . getRuleExc lus ionsSource ( ) ;

300 }

253

Page 272: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public List<RuleMul tep l i c i ty> getRulesMulteListData ( ) {questionMngr . r e f r e s h ( re ferenceAnswer ) ;

return re ferenceAnswer . g e t R u l e M u l t e p l i c i t i e s ( ) ;

}

public void c reateRule ( RuleExclus ion r ) throws SaveException {r . s e tAlternat iveAnswerSource ( re ferenceAnswer ) ;

r . s e t S i l ( fa l se ) ;

310 ruleMngr . saveRule ( r ) ;

qstUI . e x c l u s i o n L i s t ( ) ;

}

public void c reateRule ( Ru l eMul t ep l i c i ty r ) throws SaveException {r . s e tAl te rnat iveAnswer ( re ferenceAnswer ) ;

ruleMngr . saveRule ( r ) ;

qstUI . m u l t e p l i c i t y L i s t ( ) ;

}

320 private class RulesExc luSe lec ted implements Property . ValueChangeListener {

@Override

public void valueChange ( ValueChangeEvent event ) {r e f e r enceRu l eExc lu s i on = ( RuleExclus ion ) qstUI . ru le sExc luTable

. getValue ( ) ;

qstUI . e x c l u s i o n D e t a i l s ( ) ;

}}

330 private class RulesMultepSe lected implements Property . ValueChangeListener {

@Override

public void valueChange ( ValueChangeEvent event ) {r e f e r e n c e R u l e M u l t e p l i c i t y = ( Ru l eMul t ep l i c i ty ) qstUI . ru lesMultTable

. getValue ( ) ;

qstUI . m u l t e p l i c i t y D e t a i l s ( ) ;

}}

340 public RulesExc luSe lec ted ge tRu le sExc luSe l ec t ed ( ) {return new RulesExc luSe lec ted ( ) ;

}

public RulesMultepSe lected getRulesMultepSe lected ( ) {return new RulesMultepSe lected ( ) ;

}

public Quest ionna i re ge tRe fQuest ionna i r e ( ) {i f ( r e f e r e n c e Q u e s t i o n n a i r e != null )

350 questionMngr . r e f r e s h ( r e f e r e n c e Q u e s t i o n n a i r e ) ;

return r e f e r e n c e Q u e s t i o n n a i r e ;

}

public Question getReferenceQuest ion ( ) {i f ( r e f e r enceQues t i on != null )

questionMngr . r e f r e s h ( r e f e r enceQues t i on ) ;

return r e f e r enceQues t i on ;

254

Page 273: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

360 private void checkS i lQues t i on ( ) throws SaveException {i f ( r e f e r e n c e Q u e s t i o n n a i r e . g e tS i lQue s t i on ( ) == null ) {

Question s = new Question ( ) ;

s . s e tQue s t i onna i r e ( r e f e r e n c e Q u e s t i o n n a i r e ) ;

s . s e tQuest ion ( ”What i s the minimum SIL to be achieved ?” ) ;

s . setQuestionCode ( Si lQuest ionCode ) ;

s . s e t S i n g l e M u l t i p l e ( ”n . .m” ) ;

s . setLowerbound (1) ;

s . setUpperbound (1) ;

s . setOpenQuestion ( ”no” ) ;

370 s . s e tS i lDependent ( fa l se ) ;

i f ( cntxtPackage == null )

in i tCntxtPackage ( ) ;

s . setMpackage ( cntxtPackage ) ;

Mclass m = null ;

i f ( cntxtPackage . ge tMc las se s ( ) != null

&& cntxtPackage . ge tMc las se s ( ) . s i z e ( ) > 0)

m = cntxtPackage . ge tMc las se s ( ) . get (0 ) ;

s . s e tMc las s (m) ;

questionMngr . saveQuest ion ( s ) ;

380 Alternat iveAnswer [ ] a = new Alternat iveAnswer [ 5 ] ;

for ( int i = 1 ; i < 5 ; i++) {a [ i ] = new Alternat iveAnswer ( ) ;

a [ i ] . s e tQuest ion ( s ) ;

a [ i ] . setAnswer ( ”SIL−” + i ) ;

a [ i ] . setAnswerCode ( ”SIL” + i ) ;

a [ i ] . s e tS i lMinLeve l (0 ) ;

questionMngr . saveAnswer ( a [ i ] ) ;

}RuleExclus ion r ;

390 for ( int i = 1 ; i < 5 ; i++) {for ( int j = i + 1 ; j < 5 ; j++) {

r = new RuleExclus ion ( ) ;

r . s e tAlternat iveAnswerSource ( a [ i ] ) ;

r . se tAlternat iveAnswerTarget ( a [ j ] ) ;

r . s e t S i l ( fa l se ) ;

ruleMngr . saveRule ( r ) ;

}}r e f e r e n c e Q u e s t i o n n a i r e . s e t S i l Q u e s t i o n ( s ) ;

400 questionMngr . saveQuest ion ( s ) ;

questionMngr . r e f r e s h ( s ) ;

questionMngr . r e f r e s h ( r e f e r e n c e Q u e s t i o n n a i r e ) ;

}}

public StreamResource expor tP ieClas s ( ) {i f ( r e s o u r s e P i e C l a s s == null ) {

r e s o u r s e P i e C l a s s = new StreamResource (null , ” c l sCoverage . png” , appl ) ;

}410 StreamResource . StreamSource source = new StreamResource . StreamSource ( ) {

public InputStream getStream ( ) {St r ing e r r o r = ” e r r o r ” ;

byte [ ] da t i = e r r o r . getBytes ( ) ;

255

Page 274: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

dat i = getPlotBytes ( getStreamPieClass (400 , 350) ) ;

i f ( da t i == null )

da t i = e r r o r . getBytes ( ) ;

return new ByteArrayInputStream ( dat i ) ;

}} ;

420 StreamResource r = r e s o u r s e P i e C l a s s ;

r . setStreamSource ( source ) ;

r . setMIMEType( ” image/png” ) ;

r . setCacheTime(−1) ;

return r ;

}

public BufferedImage getStreamPieClass ( int w, int h) {LinkedHashMap<Str ing , Integer> mappa = new LinkedHashMap<Str ing , Integer >() ;

int to t = 0 ;

430 List<Mpackage> pkgs = r e f e r e n c e Q u e s t i o n n a i r e . getModel ( ) . getMpackages ( ) ;

for ( Mpackage p : pkgs )

to t += p . getMclas se s ( ) . s i z e ( ) ;

TreeSet<Integer> unique = new TreeSet<Integer >() ;

for ( Question q : r e f e r e n c e Q u e s t i o n n a i r e . getQuest ions ( ) ) {i f ( q . getMclass ( ) != null )

unique . add ( q . getMclass ( ) . g e tC la s s Id ( ) ) ;

}mappa . put ( ”WITH QUESTIONS” , unique . s i z e ( ) ) ;

mappa . put ( ”WITHOUT QUESTIONS” , to t − unique . s i z e ( ) ) ;

440 Color [ ] c o l o r s = { new Color (255 , 127 , 42) , Color . yel low , Color . green ,

Color . red , new Color (255 , 92 , 255) , new Color (92 , 255 , 255) ,

Color . orange , new Color (255 , 178 , 178) , new Color (255 , 92 , 92) ,

new Color (92 , 92 , 255) , new Color (92 , 255 , 92) ,

new Color (255 , 255 , 92) , Color . l i ghtGray } ;

PieChart pdf = new PieChart (mappa , ” C la s s e s coverage ” , c o l o r s ) ;

return pdf . ge tP lo t (w, h) ;

}

public StreamResource exportPiePackage ( ) {450 i f ( resoursePiePackage == null ) {

resoursePiePackage = new StreamResource (null , ”pkgCoverage . png” ,

appl ) ;

}StreamResource . StreamSource source = new StreamResource . StreamSource ( ) {

public InputStream getStream ( ) {St r ing e r r o r = ” e r r o r ” ;

byte [ ] da t i = e r r o r . getBytes ( ) ;

da t i = getPlotBytes ( getStreamPiePackage (400 , 350) ) ;

i f ( da t i == null )

460 dat i = e r r o r . getBytes ( ) ;

return new ByteArrayInputStream ( dat i ) ;

}} ;

StreamResource r = resoursePiePackage ;

r . setStreamSource ( source ) ;

r . setMIMEType( ” image/png” ) ;

r . setCacheTime(−1) ;

return r ;

}

256

Page 275: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

470public BufferedImage getStreamPiePackage ( int w, int h) {

LinkedHashMap<Str ing , Integer> mappa = new LinkedHashMap<Str ing , Integer >() ;

L i s t<Mpackage> pkgs = r e f e r e n c e Q u e s t i o n n a i r e . getModel ( ) . getMpackages ( ) ;

int to t = pkgs . s i z e ( ) ;

TreeSet<Integer> unique = new TreeSet<Integer >() ;

for ( Question q : r e f e r e n c e Q u e s t i o n n a i r e . getQuest ions ( ) ) {i f ( q . getMpackage ( ) != null )

unique . add ( q . getMpackage ( ) . getPackageId ( ) ) ;

}480 mappa . put ( ”WITH QUESTIONS” , unique . s i z e ( ) ) ;

mappa . put ( ”WITHOUT QUESTIONS” , to t − unique . s i z e ( ) ) ;

Color [ ] c o l o r s = { new Color (255 , 127 , 42) , Color . yel low , Color . green ,

Color . red , new Color (255 , 92 , 255) , new Color (92 , 255 , 255) ,

Color . orange , new Color (255 , 178 , 178) , new Color (255 , 92 , 92) ,

new Color (92 , 92 , 255) , new Color (92 , 255 , 92) ,

new Color (255 , 255 , 92) , Color . l i ghtGray } ;

PieChart pdf = new PieChart (mappa , ” Packages coverage ” , c o l o r s ) ;

return pdf . ge tP lo t (w, h) ;

}490

public byte [ ] getPlotBytes ( BufferedImage image ) {ByteArrayOutputStream imagebuf f e r = new ByteArrayOutputStream ( ) ;

try {imagebuf f e r = new ByteArrayOutputStream ( ) ;

ImageIO . wr i t e ( image , ”png” , imagebuf f e r ) ;

return imagebuf f e r . toByteArray ( ) ;

} catch ( IOException e ) {return null ;

500 }}

public void r e f r e s h ( Question q ) {questionMngr . r e f r e s h ( q ) ;

}

public void r e f r e s h ( Alternat iveAnswer ans ) {questionMngr . r e f r e s h ( ans ) ;

}510

public Alternat iveAnswer getReferenceAnswer ( ) {return re ferenceAnswer ;

}

public void a l t e r n a t i v e S e l e c t e d D e t a i l s ( I n t e g e r a id ) {re ferenceAnswer = questionMngr . getAltAnswer ( a id ) ;

qstUI . answerDeta i l s ( ) ;

}}

D.2.13 Classe SaveException.java

package i t . uniroma2 . norge . c o n t r o l l e r ;

257

Page 276: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public class SaveException extends Exception

{

private stat ic f ina l long se r ia lVer s ionUID = 2512384720862829678L ;

public SaveException ( St r ing msg)

{10 super (msg) ;

}

}

D.2.14 Classe UmlModelCtrl.java

package i t . uniroma2 . norge . c o n t r o l l e r ;

import i t . jaxb . e co re . D e t a i l s ;

import i t . jaxb . e co re . EAnnotations ;

import i t . jaxb . e co re . E C l a s s i f i e r s ;

import i t . jaxb . e co re . E L i t e r a l s ;

import i t . jaxb . e co re . EPackage ;

import i t . jaxb . e co re . EStructura lFeatures ;

import i t . jaxb . e co re . ESubpackages ;

10 import i t . jaxb . e co r ed i ag . Chi ldren ;

import i t . jaxb . e co r ed i ag . Diagram ;

import i t . jaxb . e co r ed i ag . Edges ;

import i t . jaxb . e co r ed i ag . LayoutConstraint ;

import i t . uniroma2 . norge . model . ClassManager ;

import i t . uniroma2 . norge . model . ModelManager ;

import i t . uniroma2 . norge . model . PackageManager ;

import i t . uniroma2 . norge . model . jpa . DiagChi ldren ;

import i t . uniroma2 . norge . model . jpa . DiagEdge ;

import i t . uniroma2 . norge . model . jpa . Mclass ;

20 import i t . uniroma2 . norge . model . jpa . Mf ie ld ;

import i t . uniroma2 . norge . model . jpa . M l i t e r a l ;

import i t . uniroma2 . norge . model . jpa . Model ;

import i t . uniroma2 . norge . model . jpa . Mpackage ;

import i t . uniroma2 . norge . web . ModelUI ;

import i t . uniroma2 . norge . web . Tes iwebAppl icat ion ;

import java . i o . IOException ;

import java . i o . OutputStream ;

import java . i o . Str ingReader ;

30 import java . u t i l . ArrayList ;

import java . u t i l . I t e r a t o r ;

import java . u t i l . L i s t ;

import javax . xml . bind . JAXBContext ;

import javax . xml . bind . JAXBException ;

import javax . xml . bind . Unmarshal ler ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

258

Page 277: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

40 import com . vaadin . u i . MenuBar .Command;

import com . vaadin . u i . MenuBar . MenuItem ;

import com . vaadin . u i . Upload . Rece iver ;

public class UmlModelCtrl implements Command, Property . ValueChangeListener ,

Rece iver {

private TesiwebAppl icat ion appl ;

private ModelManager modelMngr ;

50private PackageManager packageMngr ;

private ClassManager classMngr ;

private ModelUI modelUI ;

private Model referenceNewModel ;

private St r ing e c o r e F i l e ;

60private St r ing eco r eD iagF i l e ;

public UmlModelCtrl ( f ina l TesiwebAppl icat ion appl ) {modelMngr = new ModelManager ( ) ;

packageMngr = new PackageManager ( ) ;

c lassMngr = new ClassManager ( ) ;

this . appl = appl ;

modelUI = new ModelUI ( this . appl ) ;

}70

private boolean i n i tDatabase ( ) {i f ( modelMngr . v iewAl l ( ) == null | | modelMngr . v iewAl l ( ) . s i z e ( ) == 0) {

Model m = new Model ( ) ;

m. s e t D e s c r i p t i o n ( ”TMP Model” ) ;

try {modelMngr . saveModel (m) ;

System . out

. p r i n t l n ( ” Creato i l model lo con ID ” + m. getModelId ( ) ) ;

} catch ( SaveException e ) {80 }

}i f ( packageMngr . v iewAl l ( ) == null | | packageMngr . v iewAl l ( ) . s i z e ( ) == 0) {

Model mdl = modelMngr . v iewAl l ( ) . get (0 ) ;

Mpackage p = new Mpackage ( ) ;

p . setName ( ”TMP Package” ) ;

p . setPath ( ”tmp” ) ;

p . setModel ( mdl ) ;

try {packageMngr . savePackage (p) ;

90 System . out . p r i n t l n ( ” Creato i l package con ID ”

+ p . getPackageId ( ) + ” ne l model lo ”

+ p . getModel ( ) . getModelId ( ) ) ;

} catch ( SaveException e ) {}

}

259

Page 278: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

i f ( classMngr . v iewAl l ( ) == null | | classMngr . v iewAl l ( ) . s i z e ( ) == 0) {Mpackage pck = packageMngr . v iewAl l ( ) . get (0 ) ;

Mclass c = new Mclass ( ) ;

c . setName ( ”TMP c l a s s ” ) ;

100 c . setMpackage ( pck ) ;

try {classMngr . saveClas s ( c ) ;

} catch ( SaveException e ) {}c = new Mclass ( ) ;

c . setName ( ” St r ing ” ) ;

c . setCanonicalName ( ”#//EString ” ) ;

c . setMpackage ( pck ) ;

try {110 classMngr . saveClas s ( c ) ;

} catch ( SaveException e ) {}c = new Mclass ( ) ;

c . setName ( ” I n t e g e r ” ) ;

c . setCanonicalName ( ”#//EInt” ) ;

c . setMpackage ( pck ) ;

try {classMngr . saveClas s ( c ) ;

} catch ( SaveException e ) {120 }

}return true ;

}

public List<Model> getLis tData ( ) {return modelMngr . v iewAl l ( ) ;

}

@Override

130 public void menuSelected ( MenuItem se l e c t ed I t em ) {St r ing item = null ;

i f ( s e l e c t ed I t em != null )

item = se l e c t ed I t em . getText ( ) ;

appl . showNot i f i c a t i on ( item ) ;

appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

i f ( item != null && item . equa l s ( ”Add UML” ) )

modelUI . umlAdd ( ) ;

else

modelUI . umlList ( ) ;

140 }

@Override

public void valueChange ( ValueChangeEvent event ) {modelUI . umlDeta i l s ( ) ;

}

public void c rea teStep1 ( Model mdl ) {referenceNewModel = mdl ;

modelUI . umlAddLoadEcore ( referenceNewModel ) ;

150 }

260

Page 279: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void c rea teStep2 ( ) {e c o r e F i l e = new St r ing ( f i l e C o n t e n t ) ;

modelUI . umlAddLoadEcoreDiag ( referenceNewModel ) ;

}

public void c rea teStep3 ( ) throws SaveException {e co r eD iagF i l e = new St r ing ( f i l e C o n t e n t ) ;

referenceNewModel . setEcoreXml ( e c o r e F i l e ) ;

160 referenceNewModel . setEcorediagXml ( e co r eD iagF i l e ) ;

i t . jaxb . e co re . ObjectFactory ofEcore = new i t . jaxb . e co re . ObjectFactory ( ) ;

i t . jaxb . e co r ed i ag . ObjectFactory ofEcoreDiag = new

i t . jaxb . e co r ed i ag . ObjectFactory ( ) ;

try {createModelComponents ( ofEcore , ofEcoreDiag ) ;

modelMngr . populateReferencePLSSQL ( ) ;

modelUI . umlList ( ) ;

} catch ( JAXBException e ) {e . pr intStackTrace ( ) ;

throw new SaveException ( ” I t ’ s not p o s s i b i b l e to i n s t a n t i a t e JAXB” ) ;

170 }}

private void createModelComponents ( i t . jaxb . e co re . ObjectFactory ofEcore ,

i t . jaxb . e co r ed i ag . ObjectFactory ofEcoreDiag ) throws JAXBException ,

SaveException {JAXBContext context = JAXBContext . newInstance ( o fEcore . ge tC la s s ( )

. getPackage ( ) . getName ( ) ) ;

Unmarshal ler unmarsha l l e r = context . c reateUnmarsha l l e r ( ) ;

S t r ing e c o r e F i l e 2 = new St r ing ( e c o r e F i l e ) ;

180 e c o r e F i l e 2 = e c o r e F i l e 2 . r e p l a c e ( ” x s i : type ” , ” x s i t y p e ” ) ;

e c o r e F i l e 2 = e c o r e F i l e 2 . r e p l a c e (

” http ://www. w3 . org /2001/XMLSchema−i n s t ance ” , ”INST” ) ;

e c o r e F i l e 2 = e c o r e F i l e 2 . r e p l a c e (

” ecore : EDataType http ://www. e c l i p s e . org /emf /2002/ Ecore#//” ,

”#//GenericPackage /” ) ;

EPackage pack = ( EPackage ) unmarsha l l e r . unmarshal (new Str ingReader (

e c o r e F i l e 2 ) ) ;

L i s t<ESubpackages> subs = pack . getESubpackages ( ) ;

referenceNewModel . setMpackages ( decodePackages ( subs , 0) ) ;

190 modelMngr . saveModel ( referenceNewModel ) ;

JAXBContext contextDiag = JAXBContext . newInstance ( ofEcoreDiag

. ge tC la s s ( ) . getPackage ( ) . getName ( ) ) ;

Unmarshal ler unmarshal lerDiag = contextDiag . c reateUnmarsha l l e r ( ) ;

S t r ing eco r eDiagF i l e2 = new St r ing ( e co r eD iagF i l e ) ;

e co r eD iagF i l e2 = ecoreD iagF i l e2 . r e p l a c e ( ” x s i : n i l ” , ” x s i n i l ” ) ;

e co r eD iagF i l e2 = ecoreD iagF i l e2 . r e p l a c e ( ” x s i : n i l n i l ” , ” x s i n i l n i l ” ) ;

e co r eD iagF i l e2 = ecoreD iagF i l e2 . r e p l a c e (

” http ://www. w3 . org /2001/XMLSchema−i n s t ance ” ,

” http ://www. w3 . org /2001/XMLSchema−INST” ) ;

200 Diagram packDiag = ( Diagram ) unmarshal lerDiag

. unmarshal (new Str ingReader ( e co r eD iagF i l e2 ) ) ;

L i s t<Children> ch lds = packDiag . getChi ldren ( ) ;

decodeChi ldren ( ch lds ) ;

L i s t<Edges> edgs = packDiag . getEdges ( ) ;

decodeEdge ( edgs ) ;

}

261

Page 280: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private List<Mpackage> decodePackages ( Li s t<ESubpackages> subs , int l i v e l l o ) {I t e r a t o r <ESubpackages> i t = subs . i t e r a t o r ( ) ;

210 List<Mpackage> mpackages = new ArrayList<Mpackage>() ;

while ( i t . hasNext ( ) ) {ESubpackages pkg = i t . next ( ) ;

Mpackage e = new Mpackage ( ) ;

i f ( l i v e l l o == 0)

e . setModel ( referenceNewModel ) ;

e . setName ( pkg . getName ( ) ) ;

S t r ing canonicalName = ”#//” + pkg . getName ( ) ;

e . setPath ( canonicalName ) ;

e . setCanonicalName ( canonicalName ) ;

220 List<E C l a s s i f i e r s > c l s s = pkg . g e t E C l a s s i f i e r s ( ) ;

I t e r a t o r <E C l a s s i f i e r s > i t c = c l s s . i t e r a t o r ( ) ;

L i s t<Mclass> mclasse s = new ArrayList<Mclass >() ;

while ( i t c . hasNext ( ) ) {E C l a s s i f i e r s c l s = i t c . next ( ) ;

Mclass c = new Mclass ( ) ;

c . setMpackage ( e ) ;

c . setName ( c l s . getName ( ) ) ;

S t r ing canonicalNameClass = canonicalName + ”/” + c l s . getName ( ) ;

c . setCanonicalName ( canonicalNameClass ) ;

230 c . setSuperType ( c l s . getESuperTypes ( ) ) ;

EAnnotations ann = c l s . getEAnnotations ( ) ;

i f ( ann != null ) {D e t a i l s det = ann . g e t D e t a i l s ( ) ;

i f ( det != null ) {St r ing v = det . getValue ( ) ;

c . setAnnotat ion ( v ) ;

}}St r ing tmp = c l s . getXsiType ( ) ;

240 c . s e tXs i type (tmp) ;

L i s t<ELi te ra l s> l i t s = c l s . g e t E L i t e r a l s ( ) ;

I t e r a t o r <ELi te ra l s> i t l = l i t s . i t e r a t o r ( ) ;

L i s t<Ml i t e ra l> m l i t e r a l s = new ArrayList<Ml i t e ra l >() ;

while ( i t l . hasNext ( ) ) {E L i t e r a l s l t s = i t l . next ( ) ;

M l i t e r a l l = new M l i t e r a l ( ) ;

l . s e tMc las s ( c ) ;

l . setValue ( l t s . getName ( ) ) ;

m l i t e r a l s . add ( l ) ;

250 }c . s e t M l i t e r a l s ( m l i t e r a l s ) ;

L i s t<EStructura lFeatures> f i e l d s = c l s . g e tESt ruc tura lFeature s ( ) ;

I t e r a t o r <EStructura lFeatures> i t f = f i e l d s . i t e r a t o r ( ) ;

L i s t<Mfield> m f i e l d s = new ArrayList<Mfield >() ;

while ( i t f . hasNext ( ) ) {EStructura lFeature s f l s = i t f . next ( ) ;

Mf ie ld f = new Mfie ld ( ) ;

f . setOwnerClass ( c ) ;

f . setName ( f l s . getName ( ) ) ;

260 f . s e tOppos i te ( f l s . getEOpposite ( ) ) ;

f . setType ( f l s . getEType ( ) ) ;

f . setLowerBound ( f l s . getLowerBound ( ) ) ;

262

Page 281: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

f . setUpperBound ( f l s . getUpperBound ( ) ) ;

S t r ing canonicalName2Field = canonicalNameClass + ”/”

+ f l s . getName ( ) ;

f . setCanonicalName ( canonicalName2Field ) ;

m f i e l d s . add ( f ) ;

}c . s e t F i e l d s ( m f i e l d s ) ;

270 mclasse s . add ( c ) ;

}e . s e tMc la s s e s ( mc las se s ) ;

mpackages . add ( e ) ;

}{

Mpackage pck = new Mpackage ( ) ;

L i s t<Mclass> mclasse s = new ArrayList<Mclass >() ;

pck . setCanonicalName ( ”#//GenericPackage ” ) ;

pck . setName ( ”#//GenericPackage ” ) ;

280 Mclass c = new Mclass ( ) ;

c . setName ( ” St r ing ” ) ;

c . setCanonicalName ( ”#//EString ” ) ;

c . setMpackage ( pck ) ;

mc las se s . add ( c ) ;

c = new Mclass ( ) ;

c . setName ( ” St r ing ” ) ;

c . setCanonicalName ( ”#//EInt” ) ;

c . setMpackage ( pck ) ;

mc las se s . add ( c ) ;

290 pck . s e tMc la s s e s ( mc las se s ) ;

mpackages . add ( pck ) ;

}{

Mpackage pck = new Mpackage ( ) ;

L i s t<Mclass> mclasse s = new ArrayList<Mclass >() ;

pck . setCanonicalName ( ”#//D e f i n i t i o n o f C o n t e x t ” ) ;

pck . setName ( ” D e f i n i t i o n o f C o n t e x t ” ) ;

Mclass c = new Mclass ( ) ;

c . setName ( ”Context” ) ;

300 c . setCanonicalName ( ”#//Context” ) ;

c . setMpackage ( pck ) ;

mc las se s . add ( c ) ;

pck . s e tMc la s s e s ( mc las se s ) ;

mpackages . add ( pck ) ;

}return mpackages ;

}

private void populateRe fe rence ( ) throws SaveException {310 Model tmpModel = modelMngr . searchModelById ( referenceNewModel

. getModelId ( ) ) ;

L i s t<Mpackage> pkgs = tmpModel . getMpackages ( ) ;

I t e r a t o r <Mpackage> i t p = pkgs . i t e r a t o r ( ) ;

while ( i t p . hasNext ( ) ) {Mpackage p = i t p . next ( ) ;

L i s t<Mclass> c l s s = p . getMc las se s ( ) ;

I t e r a t o r <Mclass> i t c = c l s s . i t e r a t o r ( ) ;

while ( i t c . hasNext ( ) ) {

263

Page 282: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

Mclass c = i t c . next ( ) ;

320 St r ing super t = c . getSuperType ( ) ;

i f ( super t != null && ! super t . equa l s ( ”” ) ) {Mclass p a r e n t c l a s s = modelMngr . searchClassByName ( super t ) ;

i f ( p a r e n t c l a s s != null )

c . s e tParentClas s ( p a r e n t c l a s s ) ;

}List<Mfield> f l d s = c . g e t F i e l d s ( ) ;

I t e r a t o r <Mfield> i t f = f l d s . i t e r a t o r ( ) ;

while ( i t f . hasNext ( ) ) {Mfie ld f = i t f . next ( ) ;

330 St r ing t = f . getType ( ) ;

i f ( t != null && ! t . equa l s ( ”” ) ) {Mclass type = modelMngr . searchClassByName ( t ) ;

i f ( type != null )

f . setTypeClass ( type ) ;

}St r ing f2 = f . getOppos ite ( ) ;

i f ( f 2 != null && ! f2 . equa l s ( ”” ) ) {Mfie ld fopp = modelMngr . searchFieldByName ( f2 ) ;

i f ( fopp != null )

340 f . s e tOppos i t eF i e ld ( fopp ) ;

}}

}}modelMngr . saveModel ( tmpModel ) ;

}

private List<DiagChildren> decodeChi ldren ( Lis t<Children> ch lds ) {ArrayList<DiagChildren> r i s = new ArrayList<DiagChildren >() ;

350 I t e r a t o r <Children> i t = ch lds . i t e r a t o r ( ) ;

while ( i t . hasNext ( ) ) {Chi ldren c = i t . next ( ) ;

i f ( c . getElement ( ) != null ) {DiagChi ldren dc = new DiagChi ldren ( ) ;

S t r ing h r e f = c . getElement ( ) . getHre f ( ) ;

dc . s e tHre f ( h r e f ) ;

int type = c . getChildrenType ( ) . intValue ( ) ;

i f ( type == 1002 | | type == 2003) {dc . setType ( type ) ;

360 dc . s e t I d e n t ( c . getXmiId ( ) ) ;

dc . setXpos ( c . getLayoutConstra int ( ) . getX ( ) . intValue ( ) ) ;

dc . setYpos ( c . getLayoutConstra int ( ) . getY ( ) . intValue ( ) ) ;

LayoutConstraint l c = c . getLayoutConstra int ( ) ;

i f ( l c != null ) {i f ( l c . getHeight ( ) != null )

dc . s e tHe ight ( l c . getHeight ( ) . intValue ( ) ) ;

i f ( l c . getWidth ( ) != null )

dc . setWidth ( l c . getWidth ( ) . intValue ( ) ) ;

}370 i f ( type == 1002) {

h r e f = h r e f . s p l i t ( ”#//” ) . t oS t r i ng ( ) ;

Mpackage p = modelMngr . searchPackageByName ( h r e f ) ;

ArrayList<Mpackage> a = new ArrayList<Mpackage>() ;

a . add (p) ;

264

Page 283: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

dc . setMpackages ( a ) ;

} else i f ( type == 2003) {h r e f = h r e f . s p l i t ( ”#//” ) . t oS t r i ng ( ) ;

Mclass p = modelMngr . searchClassByName ( h r e f ) ;

ArrayList<Mclass> a = new ArrayList<Mclass >() ;

380 a . add (p) ;

dc . s e tMc la s s e s ( a ) ;

}try {

modelMngr . saveChi ldren ( dc ) ;

} catch ( SaveException e ) {}

}}List<Children> tmp = c . getChi ldren ( ) ;

390 i f (tmp != null && tmp . s i z e ( ) > 0)

r i s . addAll ( decodeChi ldren (tmp) ) ;

}return r i s ;

}

private List<DiagEdge> decodeEdge ( Lis t<Edges> edgs ) {ArrayList<DiagEdge> r i s = new ArrayList<DiagEdge>() ;

I t e r a t o r <Edges> i t = edgs . i t e r a t o r ( ) ;

while ( i t . hasNext ( ) ) {400 Edges c = i t . next ( ) ;

DiagEdge dc = new DiagEdge ( ) ;

int type = 0 ;

dc . setType ( type ) ;

dc . s e tSource ( c . getSource ( ) ) ;

dc . se tTarget ( c . getTarget ( ) ) ;

i f ( type == 3002) {} else i f ( type == 3003) {

St r ing h r e f = c . getElement ( ) . getHre f ( ) ;

dc . s e tHre f ( h r e f ) ;

410 Mfie ld p = modelMngr . searchFieldByName ( h r e f ) ;

ArrayList<Mfield> a = new ArrayList<Mfield >() ;

a . add (p) ;

dc . s e t M f i e l d s ( a ) ;

}r i s . add ( dc ) ;

try {modelMngr . saveEdge ( dc ) ;

} catch ( SaveException e ) {e . pr intStackTrace ( ) ;

420 }}return r i s ;

}

public void update ( Model mdl ) throws SaveException {modelMngr . saveModel ( mdl ) ;

}

private St r ing f i leName ;

430

265

Page 284: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private St r ing mtype ;

private St r ing f i l e C o n t e n t ;

private int counter ;

private int t o t a l ;

@Override

440 public OutputStream rece iveUpload ( St r ing f i l ename , S t r ing MIMEType) {counter = 0 ;

t o t a l = 0 ;

f i leName = f i l ename ;

mtype = MIMEType ;

f i l e C o n t e n t = new St r ing ( ”” ) ;

return new OutputStream ( ) {

@Override

public void wr i t e ( int b) throws IOException {450 f i l e C o n t e n t += new Character ( ( char ) b) . t oS t r i ng ( ) ;

t o t a l ++;

}} ;

}

public St r ing getFileName ( ) {return f i leName ;

}

460 public St r ing getMimeType ( ) {return mtype ;

}

public int getLineBreakCount ( ) {return counter ;

}}

D.2.15 Classe UsersCtrl.java

package i t . uniroma2 . norge . c o n t r o l l e r ;

import i t . uniroma2 . norge . model . UserManager ;

import i t . uniroma2 . norge . model . jpa . User ;

import i t . uniroma2 . norge . web . Tes iwebAppl icat ion ;

import i t . uniroma2 . norge . web . UserUI ;

import java . u t i l . L i s t ;

10 import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . u i . MenuBar .Command;

import com . vaadin . u i . MenuBar . MenuItem ;

266

Page 285: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public class UsersCtr l implements Command, Property . ValueChangeListener {

private TesiwebAppl icat ion appl ;

private UserManager userMngr ;

20private UserUI userUI ;

public UsersCtr l ( Tes iwebAppl icat ion appl ) {this . appl = appl ;

userUI = new UserUI ( this . appl ) ;

userMngr = new UserManager ( ) ;

i f ( getLis tData ( ) . s i z e ( ) == 0)

in i tDatabase ( ) ;

}30

private boolean i n i tDatabase ( ) {i f ( userMngr . v iewAl l ( ) == null | | userMngr . v iewAl l ( ) . s i z e ( ) == 0) {

User u = new User ( ) ;

u . s e tUser Id (0 ) ;

u . s e tUser ( ”admin” ) ;

u . setName ( ”admin” ) ;

u . setPassword ( ”admin” ) ;

u . setPasswordcheck ( ”admin” ) ;

try {40 userMngr . saveUser (u) ;

} catch ( SaveException e ) {}u = new User ( ) ;

u . s e tUser Id (0 ) ;

u . s e tUser ( ” e t u r e l l a ” ) ;

try {userMngr . saveUser (u) ;

} catch ( SaveException e ) {}

50 }return true ;

}

@Override

public void valueChange ( ValueChangeEvent event ) {userUI . u s e r D e t a i l s ( ) ;

}

@Override

60 public void menuSelected ( MenuItem se l e c t ed I t em ) {St r ing item = null ;

i f ( s e l e c t ed I t em != null )

item = se l e c t ed I t em . getText ( ) ;

appl . showNot i f i c a t i on ( item ) ;

appl . getSubWindowManager ( ) . removeAllSubWindow ( ) ;

i f ( item != null && item . equa l s IgnoreCase ( ”add user ” ) )

userUI . userAdd ( ) ;

else

userUI . u s e r L i s t A l l ( ) ;

70 }

267

Page 286: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public List<User> getLis tData ( ) {return userMngr . v iewAl l ( ) ;

}

public void c r e a t e ( User user ) throws SaveException {user . s e tUser Id (0 ) ;

System . out . p r i n t l n ( ” Salvo l ’ utente ” + user . getUser ( ) ) ;

80 userMngr . saveUser ( user ) ;

System . out . p r i n t l n ( ” Sa lvato l ’ utente ” + user . getUser ( ) ) ;

userUI . u s e r L i s t A l l ( ) ;

}

public void update ( User user ) throws SaveException {userMngr . saveUser ( user ) ;

userUI . u s e r D e t a i l s ( ) ;

}

90 }

D.3 Package it.uniroma2.norge.ecore

D.3.1 Classe Diagram2Java.java

package i t . uniroma2 . norge . e co re ;

import i t . jaxb . e co r ed i ag . Chi ldren ;

import i t . jaxb . e co r ed i ag . Diagram ;

import i t . jaxb . e co r ed i ag . ObjectFactory ;

import java . i o . ∗ ;

import java . u t i l . I t e r a t o r ;

import java . u t i l . L i s t ;

10import javax . xml . bind . ∗ ;

public class Diagram2Java

{public stat ic void main ( St r ing args [ ] ) throws Exception

{ObjectFactory o f = new ObjectFactory ( ) ;

JAXBContext context =

JAXBContext . newInstance ( o f . g e tC la s s ( ) . getPackage ( ) . getName ( ) ) ;

Unmarshal ler unmarsha l l e r = context . c reateUnmarsha l l e r ( ) ;

20 Diagram d = ( Diagram ) unmarsha l l er . unmarshal (

new Fi leReader ( ”SysML Model M . eco r ed i ag ” ) ) ;

L i s t<Children> subs = d . getChi ldren ( ) ;

I t e r a t o r <Children> i t = subs . i t e r a t o r ( ) ;

while ( i t . hasNext ( ) )

{Chi ldren c = i t . next ( ) ;

268

Page 287: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

System . out . p r i n t ( c . getElement ( ) . getHre f ( ) ) ;

System . out . p r i n t ( ” ( ”+c . getLayoutConstra int ( ) . getX ( )+” ,

”+c . getLayoutConstra int ( ) . getY ( )+” ) \n” ) ;

L i s t<Children> subs2 = c . getChi ldren ( ) ;

30 I t e r a t o r <Children> i t 2 = subs2 . i t e r a t o r ( ) ;

while ( i t 2 . hasNext ( ) )

{Chi ldren c2 = i t 2 . next ( ) ;

System . out . p r i n t ( ”\ t ”+c2 . getXmiType ( )+” ”+c2 . getChildrenType ( )+”\n” ) ;

i f ( c2 . getElement ( ) != null )

{System . out . p r i n t ( c2 . getElement ( ) . getXmiType ( ) ) ;

System . out . p r i n t ( ” ( ”+c2 . getLayoutConstra int ( ) . getX ( )+” ,

”+c2 . getLayoutConstra int ( ) . getY ( )+” ) \n” ) ;

}40 List<Children> subs3 = c2 . getChi ldren ( ) ;

I t e r a t o r <Children> i t 3 = subs3 . i t e r a t o r ( ) ;

while ( i t 3 . hasNext ( ) )

{Chi ldren c3 = i t 3 . next ( ) ;

i f ( c3 . getElement ( ) != null )

{System . out . p r i n t ( ”\ t \ t ”+c3 . getElement ( ) . getHre f ( ) ) ;

System . out . p r i n t ( ” ( ”+c3 . getLayoutConstra int ( ) . getX ( )+” ,

”+c3 . getLayoutConstra int ( ) . getY ( )+” ) \n” ) ;

}50 }

}}

}}

D.3.2 Classe Ecore2Java.java

package i t . uniroma2 . norge . e co re ;

import i t . jaxb . e co re . E C l a s s i f i e r s ;

import i t . jaxb . e co re . EPackage ;

import i t . jaxb . e co re . ESubpackages ;

import i t . jaxb . e co re . ObjectFactory ;

import java . i o . ∗ ;

import java . u t i l . I t e r a t o r ;

10 import java . u t i l . L i s t ;

import javax . xml . bind . ∗ ;

public class Ecore2Java

{public stat ic void main ( St r ing args [ ] ) throws Exception

{ObjectFactory o f = new ObjectFactory ( ) ;

JAXBContext context =

JAXBContext . newInstance ( o f . g e tC la s s ( ) . getPackage ( ) . getName ( ) ) ;

269

Page 288: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

20 Unmarshal ler unmarsha l l e r = context . c reateUnmarsha l l e r ( ) ;

EPackage pack = ( EPackage ) unmarsha l l er . unmarshal (

new Fi leReader ( ”SysML Model M . ecore ” ) ) ;

L i s t<ESubpackages> subs = pack . getESubpackages ( ) ;

I t e r a t o r <ESubpackages> i t = subs . i t e r a t o r ( ) ;

while ( i t . hasNext ( ) )

{ESubpackages sub = i t . next ( ) ;

System . out . p r i n t l n ( sub . getName ( ) ) ;

L i s t<E C l a s s i f i e r s > c l a s s e s = sub . g e t E C l a s s i f i e r s ( ) ;

30 I t e r a t o r <E C l a s s i f i e r s > i t 2 = c l a s s e s . i t e r a t o r ( ) ;

while ( i t 2 . hasNext ( ) )

{E C l a s s i f i e r s c l a s s e = i t 2 . next ( ) ;

System . out . p r i n t l n ( ”\ t ”+c l a s s e . getName ( ) ) ;

}}

}}

D.3.3 Classe Java2Ecore.java

package i t . uniroma2 . norge . e co re ;

import i t . jaxb . e co re . EPackage ;

import java . i o . F i l eWr i t e r ;

import javax . xml . bind . JAXBContext ;

import javax . xml . bind . Marsha l l e r ;

10 public class Java2Ecore

{

public stat ic void main ( St r ing args [ ] ) throws Exception {JAXBContext context = JAXBContext . newInstance ( EPackage . class ) ;

Marsha l l e r mar sha l l e r = context . c r ea t eMar sha l l e r ( ) ;

mar sha l l e r . s e tProper ty ( Marsha l l e r .JAXB FORMATTED OUTPUT, true ) ;

EPackage pack = new EPackage ( ) ;

pack . setName ( ” t e s t s e m p l i c e ” ) ;

20 marsha l l e r . marshal ( pack , new Fi l eWr i t e r ( ” java2eco re . out . xml” ) ) ;

}}

D.4 Package it.uniroma2.norge.model

D.4.1 Classe AgreementManager.java

270

Page 289: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

package i t . uniroma2 . norge . model ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . Ent i tyTransact ion ;

import javax . p e r s i s t e n c e . Query ;

10public class AgreementManager extends GenericManager {

public AgreementManager ( ) {super ( ) ;

}

public void r e f r e s h ( Agreement p) {em. r e f r e s h (em. merge (p) ) ;

}20

public Agreement savePro j e c t ( Agreement p) throws SaveException {i f (p . getName ( ) == null | | p . getName ( ) == ”” )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (p . g e tPro j e c t Id ( ) == 0)

em. p e r s i s t (p) ;

else

em. merge (p) ;

30 t . commit ( ) ;

return p ;

}

public List<Agreement> viewAl l ( ) {Query q = em. createQuery ( ”SELECT p FROM Pro j ec t p” ) ;

return ( L i s t<Agreement>) q . g e t R e s u l t L i s t ( ) ;

}

}

D.4.2 Classe AssignmentManager.java

package i t . uniroma2 . norge . model ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . Assignment ;

import i t . uniroma2 . norge . model . jpa . Role ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . Ent i tyTransact ion ;

10 import javax . p e r s i s t e n c e . Query ;

271

Page 290: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public class AssignmentManager extends GenericManager {

public AssignmentManager ( ) {super ( ) ;

}

public void r e f r e s h ( Assignment a ) {em. r e f r e s h (em. merge ( a ) ) ;

20 }

public Assignment saveAssignment ( Assignment a ) throws SaveException {i f ( a . getUser ( ) == null | | a . g e tPro j e c t ( ) == null

| | a . getRole ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f ( a . getAssignmentId ( ) == 0)

em. p e r s i s t ( a ) ;

30 else

em. merge ( a ) ;

t . commit ( ) ;

return a ;

}

public Role saveRole ( Role a ) {Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f ( a . getRole Id ( ) == 0)

40 em. p e r s i s t ( a ) ;

else

em. merge ( a ) ;

t . commit ( ) ;

return a ;

}

public List<Assignment> viewAl l ( ) {Query q = em. createQuery ( ”SELECT a FROM Assignment a” ) ;

return ( L i s t<Assignment>) q . g e t R e s u l t L i s t ( ) ;

50 }

public List<Role> viewAl lRo les ( ) {Query q = em. createQuery ( ”SELECT r FROM Role r ” ) ;

return ( L i s t<Role>) q . g e t R e s u l t L i s t ( ) ;

}

public List<Assignment> viewByProjectId ( int p r o j e c t I d ) {Query q = em

. createQuery ( ”SELECT a FROM Assignment a WHERE p r o j e c t I d = : pid ” ) ;

60 q . setParameter ( ” pid ” , p r o j e c t I d ) ;

return ( L i s t<Assignment>) q . g e t R e s u l t L i s t ( ) ;

}

}

272

Page 291: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.4.3 Classe ClassManager.java

package i t . uniroma2 . norge . model ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . Mclass ;

import i t . uniroma2 . norge . model . jpa . Mpackage ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . Ent i tyTransact ion ;

10 import javax . p e r s i s t e n c e . Query ;

public class ClassManager extends GenericManager {

public ClassManager ( ) {super ( ) ;

}

public List<Mclass> getByCanonicalName ( St r ing c ) {Query q = em

20 . createQuery ( ”SELECT p FROM Mclass p WHERE canonicalName = : c” ) ;

q . setParameter ( ”c” , c ) ;

return ( L i s t<Mclass>) q . g e t R e s u l t L i s t ( ) ;

}

public Mclass saveClas s ( Mclass c ) throws SaveException {i f ( c . getName ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

30 i f ( c . g e tC la s s Id ( ) == 0)

em. p e r s i s t ( c ) ;

else

em. merge ( c ) ;

t . commit ( ) ;

return c ;

}

public List<Mclass> viewAl l ( ) {Query q = em. createQuery ( ”SELECT p FROM Mclass p” ) ;

40 return ( L i s t<Mclass>) q . g e t R e s u l t L i s t ( ) ;

}

public List<Mclass> viewAl l ( Mpackage pck ) {Query q = em

. createQuery ( ”SELECT p FROM Mclass p WHERE p . mpackage = : pid ” ) ;

q . setParameter ( ” pid ” , pck ) ;

return ( L i s t<Mclass>) q . g e t R e s u l t L i s t ( ) ;

}}

D.4.4 Classe DefDeliverablesManager.java

273

Page 292: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

package i t . uniroma2 . norge . model ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . D e f a u l t D e l i v e r a b l e ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . Ent i tyTransact ion ;

import javax . p e r s i s t e n c e . Query ;

10import org . e c l i p s e . p e r s i s t e n c e . c o n f i g . CacheUsage ;

import org . e c l i p s e . p e r s i s t e n c e . c o n f i g . QueryHints ;

public class DefDel iverablesManager extends GenericManager {

public DefDel iverablesManager ( ) {super ( ) ;

}

20 public void r e f r e s h ( D e f a u l t D e l i v e r a b l e r e f e r e n c e D e l i v e r a b l e ) {Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

i f ( r e f e r e n c e D e l i v e r a b l e != null )

em. r e f r e s h (em. merge ( r e f e r e n c e D e l i v e r a b l e ) ) ;

}

public D e f a u l t D e l i v e r a b l e s a v e D e l i v e r a b l e ( D e f a u l t D e l i v e r a b l e d)

30 throws SaveException {i f (d . getName ( ) == null | | d . getName ( ) == ””

| | d . g e tDe s c r i p t i on ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (d . g e t D e l i v e r a b l e I d ( ) == 0)

em. p e r s i s t (d) ;

else

em. merge (d) ;

40 em. f l u s h ( ) ;

t . commit ( ) ;

return d ;

}

public List<Defau l tDe l i v e rab l e> viewAl l ( ) {Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

50 Query q = em. createQuery ( ”SELECT p FROM D e f a u l t D e l i v e r a b l e p” ) ;

q . s e tHint ( QueryHints .CACHE USAGE, CacheUsage . DoNotCheckCache ) ;

return ( L i s t<Defau l tDe l i v e rab l e >) q . g e t R e s u l t L i s t ( ) ;

}

public D e f a u l t D e l i v e r a b l e g e t D e l i v e r a b l e ( I n t e g e r did ) {D e f a u l t D e l i v e r a b l e q = em. f i n d ( D e f a u l t D e l i v e r a b l e . class , did ) ;

274

Page 293: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return q ;

}

60 }

D.4.5 Classe DelivCategManager.java

package i t . uniroma2 . norge . model ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . Del ivCateg ;

import i t . uniroma2 . norge . model . jpa . Del ivSubcateg ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . Ent i tyTransact ion ;

10 import javax . p e r s i s t e n c e . Query ;

public class DelivCategManager extends GenericManager {

public DelivCategManager ( ) {super ( ) ;

}

public void r e f r e s h ( Del ivCateg x ) {Ent i tyTransact ion t = getNewTransaction ( ) ;

20 t . begin ( ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

em . r e f r e s h (em. merge ( x ) ) ;

}

public void r e f r e s h ( Del ivSubcateg x ) {Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

em . f l u s h ( ) ;

30 t . commit ( ) ;

em . r e f r e s h (em. merge ( x ) ) ;

}

public DelivCateg saveCategory ( Del ivCateg d) throws SaveException {i f (d . getName ( ) == null | | d . getName ( ) == ”” )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (d . getDe l ivCategId ( ) == 0)

40 em. p e r s i s t (d) ;

else

em. merge (d) ;

em . f l u s h ( ) ;

t . commit ( ) ;

return d ;

}

275

Page 294: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public Del ivSubcateg saveSubCategory ( Del ivSubcateg d) throws SaveException {i f (d . getName ( ) == null | | d . getName ( ) == ”” )

50 throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (d . getDe l ivSubcategId ( ) == 0)

em. p e r s i s t (d) ;

else

em. merge (d) ;

em . f l u s h ( ) ;

t . commit ( ) ;

return d ;

60 }

public List<DelivCateg> viewAllCateg ( ) {Query q = em. createQuery ( ”SELECT p FROM DelivCateg p” ) ;

return ( L i s t<DelivCateg >) q . g e t R e s u l t L i s t ( ) ;

}

}

D.4.6 Classe DeliverablesManager.java

package i t . uniroma2 . norge . model ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . Evidence ;

import i t . uniroma2 . norge . model . jpa . De l ive rab l eContentHi s to ry ;

import i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e ;

import i t . uniroma2 . norge . model . jpa . De l ive rab l eEv idence ;

import i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e H i s t o r y ;

import i t . uniroma2 . norge . model . jpa . DocumentHistory ;

10 import i t . uniroma2 . norge . model . jpa . Agreement ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . Ent i tyTransact ion ;

import javax . p e r s i s t e n c e . Query ;

public class Del iverablesManager extends GenericManager {

public Del iverablesManager ( ) {20 super ( ) ;

}

public void r e f r e s h ( D e l i v e r a b l e r e f e r e n c e D e l i v e r a b l e ) {Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

em . f l u s h ( ) ;

30 t . commit ( ) ;

276

Page 295: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

r e f e r e n c e D e l i v e r a b l e = em. f i n d ( r e f e r e n c e D e l i v e r a b l e . g e tC la s s ( ) ,

r e f e r e n c e D e l i v e r a b l e . g e t D e l i v e r a b l e I d ( ) ) ;

}

public D e l i v e r a b l e s a v e D e l i v e r a b l e ( D e l i v e r a b l e d) throws SaveException {i f (d . g e tPro j e c t ( ) == null | | d . getName ( ) == ””

| | d . getApprovalStatus ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

40 i f (d . g e t D e l i v e r a b l e I d ( ) == 0)

em. p e r s i s t (d) ;

else

em. merge (d) ;

em . f l u s h ( ) ;

t . commit ( ) ;

return d ;

}

public Del ive rab l eEv idence saveDe l ive rab l eEv idence ( De l ive rab l eEv idence d)

50 throws SaveException {i f (d . g e t D e l i v e r a b l e ( ) == null | | d . getAnswsetAnsw ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

i f (d . ge t Inc luded ( ) == null )

d . s e t Inc luded ( fa l se ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (d . g e tDe l i v e rab l eEv idence Id ( ) == 0)

em. p e r s i s t (d) ;

else

60 d = em. merge (d) ;

em . f l u s h ( ) ;

t . commit ( ) ;

return d ;

}

public List<Del ive rab l e> viewAl l ( ) {Query q = em. createQuery ( ”SELECT p FROM D e l i v e r a b l e p” ) ;

return ( L i s t<Del ive rab l e >) q . g e t R e s u l t L i s t ( ) ;

}70

public D e l i v e r a b l e g e t D e l i v e r a b l e ( I n t e g e r did ) {D e l i v e r a b l e q = em. f i n d ( D e l i v e r a b l e . class , did ) ;

return q ;

}

public DocumentHistory saveDocumentHist ( DocumentHistory h)

throws SaveException {i f (h . getDocument ( ) == null | | h . getUser ( ) == null

| | h . getAct ion ( ) == null )

80 throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (h . getDocumentHistoryId ( ) == 0)

em. p e r s i s t (h) ;

else

277

Page 296: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

em. merge (h) ;

em . f l u s h ( ) ;

t . commit ( ) ;

return h ;

90 }

public void r e f r e s h ( Agreement p) {Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

p = em. f i n d (p . ge tC la s s ( ) , p . g e tPro j e c t Id ( ) ) ;

}

100 public D e l i v e r a b l e H i s t o r y s a v e D e l i v e r a b l e H i s t ( D e l i v e r a b l e H i s t o r y h)

throws SaveException {i f (h . g e t D e l i v e r a b l e ( ) == null | | h . getUser ( ) == null

| | h . getAct ion ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (h . g e t D e l i v e r a b l e H i s t o r y I d ( ) == 0)

em. p e r s i s t (h) ;

else

110 em. merge (h) ;

em . f l u s h ( ) ;

t . commit ( ) ;

return h ;

}

public Del ive rab l eContentHi s to ry saveDe l i ve rab l eEv idenceHi s t (

De l ive rab l eContentHi s to ry h) throws SaveException {i f (h . getAnswsetAnsw ( ) == null | | h . getUser ( ) == null

| | h . getAct ion ( ) == null )

120 throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (h . getAnswsetHistoryId ( ) == 0)

em. p e r s i s t (h) ;

else

em. merge (h) ;

em . f l u s h ( ) ;

t . commit ( ) ;

return h ;

130 }

public Del ive rab l eEv idence getFromAnswsetAnsw ( Evidence a , D e l i v e r a b l e d) {Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

Query q = em. createQuery ( ”SELECT p FROM Del ive rab l eEv idence p ”

+ ” WHERE p . answsetAnsw = : a AND p . d e l i v e r a b l e = : d” ) ;

q . setParameter ( ”a” , a ) ;

140 q . setParameter ( ”d” , d) ;

L i s t<Del iverab leEvidence> l = ( Lis t<Del iverab leEvidence >) q

278

Page 297: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

. g e t R e s u l t L i s t ( ) ;

i f ( l != null && l . s i z e ( ) > 0)

return l . get (0 ) ;

return null ;

}

public Del ive rab l eEv idence ge tDe l i v e rab l eEv idence ( D e l i v e r a b l e d ,

Evidence aa ) {150 Query q = em. createQuery ( ”SELECT p FROM Del ive rab l eEv idence p”

+ ” WHERE p . answsetAnsw = : aa AND p . d e l i v e r a b l e = : d ” ) ;

q . setParameter ( ”aa” , aa ) ;

q . setParameter ( ”d” , d) ;

L i s t<Del iverab leEvidence> l = ( Lis t<Del iverab leEvidence >) q

. g e t R e s u l t L i s t ( ) ;

i f ( l . s i z e ( ) == 0)

return null ;

return l . get (0 ) ;

}160

public void r e f r e s h ( Evidence a ) {Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

a = em. f i n d ( a . ge tC la s s ( ) , a . getAnswsetAnswId ( ) ) ;

}

}

D.4.7 Classe DocumentsManager.java

package i t . uniroma2 . norge . model ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . Document ;

import i t . uniroma2 . norge . model . jpa . DocumentHistory ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

import java . u t i l . L i s t ;

10 import javax . p e r s i s t e n c e . Ent i tyTransact ion ;

import javax . p e r s i s t e n c e . Query ;

public class DocumentsManager extends GenericManager {

public DocumentsManager ( ) {super ( ) ;

}

20

public void r e f r e s h ( Document a ) {

279

Page 298: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

em . r e f r e s h (em. merge ( a ) ) ;

}30

public Document saveDocument ( Document d)

throws SaveException {i f (d . g e tPro j e c t ( ) == null | | d . getFi lename ( ) == ””

| | d . ge tSta tus ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (d . getDocumentId ( ) == 0)

em. p e r s i s t (d) ;

40 else

em. merge (d) ;

em . f l u s h ( ) ;

t . commit ( ) ;

return d ;

}

public List<Document> viewAl l ( ) {Query q = em. createQuery ( ”SELECT p FROM Document p” ) ;

return ( L i s t<Document>) q . g e t R e s u l t L i s t ( ) ;

50 }

public Document getDocument ( I n t e g e r qid ) {Document q = em. f i n d ( Document . class , q id ) ;

return q ;

}

public DocumentHistory saveDocumentHist ( DocumentHistory h) throws SaveException {i f (h . getDocument ( ) == null | | h . getUser ( ) == null

| | h . getAct ion ( ) == null )

60 throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (h . getDocumentHistoryId ( ) == 0)

em. p e r s i s t (h) ;

else

em. merge (h) ;

em . f l u s h ( ) ;

t . commit ( ) ;

return h ;

70 }

public void r e f r e s h ( Agreement a ) {Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

em . r e f r e s h (em. merge ( a ) ) ;

}

280

Page 299: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

80 }

D.4.8 Classe GenericManager.java

package i t . uniroma2 . norge . model ;

import javax . p e r s i s t e n c e . EntityManager ;

import javax . p e r s i s t e n c e . EntityManagerFactory ;

import javax . p e r s i s t e n c e . Ent i tyTransact ion ;

import javax . p e r s i s t e n c e . FlushModeType ;

import javax . p e r s i s t e n c e . P e r s i s t e n c e ;

public class GenericManager {10

protected EntityManager em;

public GenericManager ( ) {i f (em == null ) {

EntityManagerFactory f a c t o r y = P e r s i s t e n c e

. createEntityManagerFactory ( ”tesiWebApp” ) ;

em = f a c t o r y . createEntityManager ( ) ;

em . setFlushMode ( FlushModeType .AUTO) ;

}20 }

public Ent i tyTransact ion getNewTransaction ( ) {Ent i tyTransact ion t = em. getTransact ion ( ) ;

i f ( t . i s A c t i v e ( ) ) {try {

t . commit ( ) ;

} catch ( Exception e ) {System . out

. p r i n t l n ( ”C ’ era una t ran saz i one a t t i v a e l a commit non ha

funz ionato ! ! ! ” ) ;

30 e . pr intStackTrace ( ) ;

try {i f ( t . i s A c t i v e ( ) )

t . r o l l b a c k ( ) ;

} catch ( Exception e1 ) {System . out

. p r i n t l n ( ” . . . . e non ha funz ionato nemmeno l a r o l l b a c k ! ! ! ” ) ;

e1 . pr intStackTrace ( ) ;

}}

40 }return t ;

}}

D.4.9 Classe ModelManager.java

281

Page 300: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

package i t . uniroma2 . norge . model ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . DiagChi ldren ;

import i t . uniroma2 . norge . model . jpa . DiagEdge ;

import i t . uniroma2 . norge . model . jpa . Mclass ;

import i t . uniroma2 . norge . model . jpa . Mf ie ld ;

import i t . uniroma2 . norge . model . jpa . Model ;

import i t . uniroma2 . norge . model . jpa . Mpackage ;

10 import i t . uniroma2 . norge . model . jpa . Re lat ion ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . Ent i tyTransact ion ;

import javax . p e r s i s t e n c e . Query ;

public class ModelManager extends GenericManager {

public ModelManager ( ) {20 super ( ) ;

}

public DiagChi ldren saveChi ldren ( DiagChi ldren m) throws SaveException {i f (m. ge t Ident ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (m. getCh i ldrenId ( ) == 0)

em. p e r s i s t (m) ;

30 else

em. merge (m) ;

t . commit ( ) ;

return m;

}

public DiagEdge saveEdge ( DiagEdge m) throws SaveException {i f (m. getSource ( ) == null | | m. getTarget ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

40 t . begin ( ) ;

i f (m. getEdgeId ( ) == 0)

em. p e r s i s t (m) ;

else

em. merge (m) ;

t . commit ( ) ;

return m;

}

public Model saveModel ( Model m) throws SaveException {50 i f (m. g e tDe s c r i p t i on ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (m. getModelId ( ) == 0)

em. p e r s i s t (m) ;

else

282

Page 301: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

em. merge (m) ;

t . commit ( ) ;

return m;

60 }

public Relat ion saveRe la t ion ( Re lat ion m) throws SaveException {i f (m. getMf i e ldSource ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (m. ge tRe la t i on Id ( ) == 0)

em. p e r s i s t (m) ;

70 else

em. merge (m) ;

t . commit ( ) ;

return m;

}

public DiagChi ldren searchChi ldrenByIdent ( S t r ing source ) {Query q = em

. createQuery ( ”SELECT f FROM Mpackage f WHERE f . ident = : name” ) ;

q . setParameter ( ”name” , source ) ;

80 List<DiagChildren> r i s = ( Lis t<DiagChildren >) q . g e t S i n g l e R e s u l t ( ) ;

DiagChi ldren v = null ;

i f ( r i s != null && r i s . s i z e ( ) > 0)

v = r i s . get (0 ) ;

return v ;

}

public Mclass searchClassByName ( St r ing cname ) {Query q = em

. createQuery ( ”SELECT c FROM Mclass c WHERE c . canonicalName = : name” ) ;

90 q . setParameter ( ”name” , cname ) ;

L i s t<Mclass> r i s = ( Lis t<Mclass>) q . g e t R e s u l t L i s t ( ) ;

Mclass v = null ;

i f ( r i s != null && r i s . s i z e ( ) > 0)

v = r i s . get (0 ) ;

return v ;

}

public Mfie ld searchFieldByName ( St r ing cname ) {Query q = em

100 . createQuery ( ”SELECT f FROM Mfie ld f WHERE f . canonicalName = : name” ) ;

q . setParameter ( ”name” , cname ) ;

L i s t<Mfield> r i s = ( Lis t<Mfield >) q . g e t R e s u l t L i s t ( ) ;

Mf ie ld v = null ;

i f ( r i s != null && r i s . s i z e ( ) > 0)

v = r i s . get (0 ) ;

return v ;

}

public Model searchModelById ( int modelId ) {110 return em. f i n d ( Model . class , modelId ) ;

}

283

Page 302: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public Mpackage searchPackageByName ( St r ing cname ) {Query q = em

. createQuery ( ”SELECT f FROM Mpackage f WHERE f . canonicalName = : name” ) ;

q . setParameter ( ”name” , cname ) ;

L i s t<Mpackage> r i s = ( Lis t<Mpackage>) q . g e t R e s u l t L i s t ( ) ;

Mpackage v = null ;

i f ( r i s != null && r i s . s i z e ( ) > 0)

120 v = r i s . get (0 ) ;

return v ;

}

public List<Model> viewAl l ( ) {Query q = em. createQuery ( ”SELECT p FROM Model p” ) ;

return ( L i s t<Model>) q . g e t R e s u l t L i s t ( ) ;

}

public void populateReferencePLSSQL ( ) {130 St r ing s q l ;

Query q ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

s q l = ”CALL resolveClassName ( ) ; ” ;

q = em. createNat iveQuery ( s q l ) ;

q . executeUpdate ( ) ;

s q l = ”CALL reso lveEdges ( ) ; ” ;

q = em. createNat iveQuery ( s q l ) ;

q . executeUpdate ( ) ;

140 s q l = ”CALL classToDiagram ( ) ; ” ;

q = em. createNat iveQuery ( s q l ) ;

q . executeUpdate ( ) ;

s q l = ”CALL relat ionToDiagram ( ) ; ” ;

q = em. createNat iveQuery ( s q l ) ;

q . executeUpdate ( ) ;

t . commit ( ) ;

}

public void r e f r e s h ( Model p) {150 Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

em . r e f r e s h (em. merge (p) ) ;

}

}

D.4.10 Classe OrganizationsManager.java

package i t . uniroma2 . norge . model ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . Organizat ion ;

import java . u t i l . L i s t ;

284

Page 303: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import javax . p e r s i s t e n c e . Ent i tyTransact ion ;

import javax . p e r s i s t e n c e . Query ;

10public class OrganizationsManager extends GenericManager {

public OrganizationsManager ( ) {super ( ) ;

}

public void r e f r e s h ( Organizat ion x ) {Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

20 em. f l u s h ( ) ;

t . commit ( ) ;

em . r e f r e s h (em. merge ( x ) ) ;

}

public Organizat ion saveOrgan izat ion ( Organizat ion d) throws SaveException {i f (d . getName ( ) == null | | d . getName ( ) == ”” )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

30 i f (d . ge tOrgan i zat ionId ( ) == 0)

em. p e r s i s t (d) ;

else

em. merge (d) ;

em . f l u s h ( ) ;

t . commit ( ) ;

return d ;

}

public List<Organizat ion> viewAl l ( ) {40 Query q = em. createQuery ( ”SELECT p FROM Organizat ion p” ) ;

return ( L i s t<Organizat ion >) q . g e t R e s u l t L i s t ( ) ;

}

public Organizat ion getOrgan izat ion ( I n t e g e r did ) {Organizat ion q = em. f i n d ( Organizat ion . class , did ) ;

return q ;

}

}

D.4.11 Classe PackageManager.java

package i t . uniroma2 . norge . model ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . Model ;

import i t . uniroma2 . norge . model . jpa . Mpackage ;

import java . u t i l . L i s t ;

285

Page 304: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import javax . p e r s i s t e n c e . EntityManager ;

10 import javax . p e r s i s t e n c e . EntityManagerFactory ;

import javax . p e r s i s t e n c e . Ent i tyTransact ion ;

import javax . p e r s i s t e n c e . P e r s i s t e n c e ;

import javax . p e r s i s t e n c e . Query ;

public class PackageManager {

private EntityManagerFactory f a c t o r y ;

private EntityManager em;

20 public PackageManager ( ) {f a c t o r y = P e r s i s t e n c e . createEntityManagerFactory ( ”tesiWebApp” ) ;

em = f a c t o r y . createEntityManager ( ) ;

}

public List<Mpackage> getByCanonicalName ( St r ing c , Model m) {Query q = em

. createQuery ( ”SELECT p FROM Mpackage p WHERE p . canonicalName = : c ”

+ ” AND p . model = :m” ) ;

q . setParameter ( ”c” , c ) ;

30 q . setParameter ( ”m” , m) ;

return ( L i s t<Mpackage>) q . g e t R e s u l t L i s t ( ) ;

}

public Mpackage savePackage ( Mpackage m) throws SaveException {i f (m. getModel ( ) == null | | m. getName ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = em. getTransact ion ( ) ;

t . begin ( ) ;

i f (m. getPackageId ( ) == 0)

40 em. p e r s i s t (m) ;

else

m = em. merge (m) ;

t . commit ( ) ;

return m;

}

public List<Mpackage> viewAl l ( ) {Query q = em. createQuery ( ”SELECT p FROM Mpackage p” ) ;

return ( L i s t<Mpackage>) q . g e t R e s u l t L i s t ( ) ;

50 }}

D.4.12 Classe QuestionnaireManager.java

package i t . uniroma2 . norge . model ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . Alternat iveAnswer ;

import i t . uniroma2 . norge . model . jpa . AnswerSet ;

import i t . uniroma2 . norge . model . jpa . Evidence ;

import i t . uniroma2 . norge . model . jpa . AnswsetHistory ;

import i t . uniroma2 . norge . model . jpa . Mclass ;

286

Page 305: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import i t . uniroma2 . norge . model . jpa . Mpackage ;

10 import i t . uniroma2 . norge . model . jpa . Agreement ;

import i t . uniroma2 . norge . model . jpa . Question ;

import i t . uniroma2 . norge . model . jpa . Quest ionna i re ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . Ent i tyTransact ion ;

import javax . p e r s i s t e n c e . Query ;

public class QuestionnaireManager extends GenericManager {20

public QuestionnaireManager ( ) {super ( ) ;

}

public Alternat iveAnswer getAltAnswer ( I n t e g e r a id ) {return em. f i n d ( Alternat iveAnswer . class , a id ) ;

}

public AnswerSet getAnswerSet ( int ques t i on Id ) {30 Query q = em. createQuery ( ”SELECT a FROM Question p ”

+ ” JOIN p . answerSets a ” + ” WHERE p . ques t i on Id = : qid ” ) ;

q . setParameter ( ” qid ” , que s t i on Id ) ;

L i s t<AnswerSet> l = ( Lis t<AnswerSet>) q . g e t R e s u l t L i s t ( ) ;

i f ( l != null && l . s i z e ( ) > 0)

return l . get (0 ) ;

return null ;

}

public AnswerSet getAnswerSet ( Question qq , Agreement p) {40 Query q = em. createQuery ( ”SELECT a FROM AnswerSet a ”

+ ” WHERE a . ques t i on = : qq AND a . p r o j e c t = : p ” ) ;

q . setParameter ( ”qq” , qq ) ;

q . setParameter ( ”p” , p) ;

L i s t<AnswerSet> l = ( Lis t<AnswerSet>) q . g e t R e s u l t L i s t ( ) ;

i f ( l != null && l . s i z e ( ) > 0)

return l . get (0 ) ;

return null ;

}

50public Evidence getAnswsetAnsw ( Agreement prj , Alternat iveAnswer a id ) {

Query q = em. createQuery ( ” s e l e c t ans from AnswsetAnsw ans ”

+ ” WHERE ans . answerSet . p r o j e c t = : p r j ”

+ ” AND ans . a l t e rnat iveAnswer = : a id ” ) ;

q . setParameter ( ” p r j ” , p r j ) ;

q . setParameter ( ” a id ” , a id ) ;

L i s t<Evidence> l = ( Lis t<Evidence>) q . g e t R e s u l t L i s t ( ) ;

i f ( l != null && l . s i z e ( ) > 0)

return l . get (0 ) ;

60 return null ;

}

public void r e f r e s h ( Alternat iveAnswer a ) {a = em. f i n d ( a . ge tC la s s ( ) , a . getAnswerId ( ) ) ;

287

Page 306: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

public void r e f r e s h ( Quest ionna i re a ) {a = em. f i n d ( a . ge tC la s s ( ) , a . g e tQues t i onna i r e Id ( ) ) ;

}70

public void r e f r e s h ( AnswerSet r ) {Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

r = em. f i n d ( r . g e tC la s s ( ) , r . getAnswerSetId ( ) ) ;

}

public void r e f r e s h ( Evidence r ) {80 Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

r = em. f i n d ( r . g e tC la s s ( ) , r . getAnswsetAnswId ( ) ) ;

}

public void r e f r e s h ( Question qst ) {qst = em. f i n d ( qst . g e tC la s s ( ) , qs t . getQuest ionId ( ) ) ;

}90

public Alternat iveAnswer saveAnswer ( Alternat iveAnswer ans )

throws SaveException {i f ( ans . getAnswer ( ) == null | | ans . getAnswer ( ) == ””

| | ans . getQuest ion ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

i f ( ! t . i s A c t i v e ( ) )

t . begin ( ) ;

100 i f ( ans . getAnswerId ( ) == 0)

em. p e r s i s t ( ans ) ;

else

em. merge ( ans ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

return ans ;

}

public AnswerSet saveAnswerSet ( AnswerSet ans ) throws SaveException {110 i f ( ans . getQuest ion ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f ( ans . getAnswerSetId ( ) == 0)

em. p e r s i s t ( ans ) ;

else

em. merge ( ans ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

120 return ans ;

288

Page 307: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

public Evidence saveAnswsetAnsw ( Evidence ans ) throws SaveException {i f ( ans . getAlternat iveAnswer ( ) == null | | ans . getAnswerSet ( ) == null

| | ans . getApprovat ionStatus ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f ( ans . getAnswsetAnswId ( ) == 0)

130 em. p e r s i s t ( ans ) ;

else

em. merge ( ans ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

return ans ;

}

public Question saveQuest ion ( Question p) throws SaveException {140 i f (p . getQuest ion ( ) == null | | p . getQuest ion ( ) == ”” )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (p . getQuest ionId ( ) == 0)

em. p e r s i s t (p) ;

else

em. merge (p) ;

em . f l u s h ( ) ;

t . commit ( ) ;

150 return p ;

}

public Quest ionna i re saveQuest ionna i r e ( Quest ionna i re p)

throws SaveException {i f (p . getModel ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (p . ge tQues t i onna i r e Id ( ) == 0)

160 em. p e r s i s t (p) ;

else

em. merge (p) ;

em . f l u s h ( ) ;

t . commit ( ) ;

return p ;

}

public List<Quest ionnaire> viewAl l ( ) {Query q = em. createQuery ( ”SELECT p FROM Quest ionna i re p” ) ;

170 return ( L i s t<Quest ionnaire >) q . g e t R e s u l t L i s t ( ) ;

}

public List<Question> viewAl lQuest ions ( ) {Query q = em. createQuery ( ”SELECT p FROM Question p” ) ;

return ( L i s t<Question >) q . g e t R e s u l t L i s t ( ) ;

}

289

Page 308: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public List<Question> viewAl lQuest ions ( Mpackage pkg ) {i f ( pkg == null )

180 return null ;

Query q = em. createQuery ( ”SELECT p FROM Question p”

+ ” WHERE p . mpackage = : pkg ” ) ;

q . setParameter ( ”pkg” , pkg ) ;

return ( L i s t<Question >) q . g e t R e s u l t L i s t ( ) ;

}

public List<AnswerSet> viewAllAnswerSets ( Agreement prj , Mpackage pkg ) {i f ( pkg == null )

return null ;

190 Query q = em. createQuery ( ”SELECT p FROM AnswerSet p”

+ ” WHERE p . p r o j e c t = : p r j AND (p . ques t i on . mpackage = : pkg ) ” ) ;

q . setParameter ( ” p r j ” , p r j ) ;

q . setParameter ( ”pkg” , pkg ) ;

return ( L i s t<AnswerSet>) q . g e t R e s u l t L i s t ( ) ;

}

public List<AnswerSet> viewAllAnswerSets ( Agreement p r j ) {Query q = em. createQuery ( ”SELECT p FROM AnswerSet p”

+ ” WHERE p . p r o j e c t = : p r j ” ) ;

200 q . setParameter ( ” p r j ” , p r j ) ;

return ( L i s t<AnswerSet>) q . g e t R e s u l t L i s t ( ) ;

}

public List<Mpackage> getPackagesForQuest ionnaire ( Quest ionna i re qst ) {i f ( qs t == null )

return null ;

Query q = em. createQuery ( ”SELECT p FROM Mpackage p”

+ ” WHERE EXISTS (SELECT q FROM Question q”

+ ” WHERE q . q u e s t i o n n a i r e = : qst ” + ” AND q . mpackage = p) ” ) ;

210 q . setParameter ( ” qst ” , qs t ) ;

return ( L i s t<Mpackage>) q . g e t R e s u l t L i s t ( ) ;

}

public Question getQuest ion ( I n t e g e r qid ) {Question q = em. f i n d ( Question . class , q id ) ;

return q ;

}

public AnswsetHistory saveAnswsetHist ( AnswsetHistory ans )

220 throws SaveException {i f ( ans . getAnswerSet ( ) == null | | ans . getUser ( ) == null

| | ans . getAct ion ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f ( ans . getAnswsetHistoryId ( ) == 0)

em. p e r s i s t ( ans ) ;

else

em. merge ( ans ) ;

230 em. f l u s h ( ) ;

t . commit ( ) ;

return ans ;

290

Page 309: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

public Quest ionna i re search ( I n t e g e r i ) {Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

em . f l u s h ( ) ;

t . commit ( ) ;

240 return em. f i n d ( Quest ionna i re . class , i ) ;

}

public List<Evidence> getEvidencesForMClass ( Mclass c ) {i f ( c == null )

return null ;

Query q = em. createQuery ( ”SELECT p FROM AnswsetAnsw p”

+ ” WHERE p . re sponse = ’ yes ’ AND p . answerSet . ques t i on . mclass = : c” ) ;

q . setParameter ( ”c” , c ) ;

return ( L i s t<Evidence>) q . g e t R e s u l t L i s t ( ) ;

250 }

}

D.4.13 Classe RuleManager.java

package i t . uniroma2 . norge . model ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . Alternat iveAnswer ;

import i t . uniroma2 . norge . model . jpa . Question ;

import i t . uniroma2 . norge . model . jpa . RuleExclus ion ;

import i t . uniroma2 . norge . model . jpa . Ru l eMul t ep l i c i ty ;

import java . u t i l . L i s t ;

10import javax . p e r s i s t e n c e . Ent i tyTransact ion ;

import javax . p e r s i s t e n c e . Query ;

public class RuleManager extends GenericManager {

public RuleManager ( ) {super ( ) ;

}

20public void r e f r e s h ( RuleExclus ion r l ) {

em. r e f r e s h (em. merge ( r l ) ) ;

}

public RuleExclus ion saveRule ( RuleExclus ion p) throws SaveException {i f (p . getAlternat iveAnswerSource ( ) == null

| | p . getAlternat iveAnswerTarget ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

30 t . begin ( ) ;

i f (p . getRuleExc lus ionId ( ) == 0)

291

Page 310: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

em. p e r s i s t (p) ;

else

em. merge (p) ;

t . commit ( ) ;

return p ;

}

public RuleMul t ep l i c i ty saveRule ( Ru l eMul t ep l i c i ty p) throws SaveException {40 i f (p . getAlternat iveAnswer ( ) == null | | p . getQuest ion ( ) == null )

throw new SaveException ( ”Datas conta in e r r o r s ” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (p . g e tRu l eMu l t ep l i c i t y Id ( ) == 0)

em. p e r s i s t (p) ;

else

em. merge (p) ;

t . commit ( ) ;

return p ;

50 }

public List<RuleExclusion> v iewAl lExc lus ion ( ) {Query q = em. createQuery ( ”SELECT p FROM Rule p ” ) ;

return ( L i s t<RuleExclusion >) q . g e t R e s u l t L i s t ( ) ;

}

public List<RuleMul tep l i c i ty> v i e w A l l M u l t e p l i c i t y ( ) {Query q = em. createQuery ( ”SELECT p FROM RuleMul t ep l i c i ty p ” ) ;

return ( L i s t<RuleMultep l i c i ty >) q . g e t R e s u l t L i s t ( ) ;

60 }

public RuleExclus ion search ( Alternat iveAnswer s , Alternat iveAnswer t ) {Query q = em

. createQuery ( ”SELECT r FROM RuleExclus ion r ”

+ ”WHERE ( r . a l te rnat iveAnswerTarget = : s OR r . a l te rnat iveAnswerTarget

=: t ) ”

+ ”AND ( r . a l t e rnat iveAnswerSource = : s OR r . a l t e rnat iveAnswerSource

=: t ) ” ) ;

q . setParameter ( ” s ” , s ) ;

q . setParameter ( ” t ” , t ) ;

L i s t<RuleExclusion> r e s = ( Lis t<RuleExclusion >) q . g e t R e s u l t L i s t ( ) ;

70 i f ( r e s != null && r e s . s i z e ( ) > 0)

return r e s . get (0 ) ;

return null ;

}

public void d e l e t e ( RuleExclus ion r ) {Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

em . remove ( r ) ;

t . commit ( ) ;

80 }

public List<RuleMul tep l i c i ty> v i e w A l l M u l t e p l i c i t y ( Question qst ) {Query q = em. createQuery ( ”SELECT p FROM RuleMul t ep l i c i ty p”

+ ” WHERE p . ques t i on = : qst ” ) ;

q . setParameter ( ” qst ” , qs t ) ;

292

Page 311: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return ( L i s t<RuleMultep l i c i ty >) q . g e t R e s u l t L i s t ( ) ;

}

}

D.4.14 Classe UserManager.java

package i t . uniroma2 . norge . model ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . Assignment ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

import i t . uniroma2 . norge . model . jpa . Role ;

import i t . uniroma2 . norge . model . jpa . User ;

import java . u t i l . L i s t ;

10import javax . p e r s i s t e n c e . Ent i tyTransact ion ;

import javax . p e r s i s t e n c e . NoResultException ;

import javax . p e r s i s t e n c e . Query ;

public class UserManager extends GenericManager {

public UserManager ( ) {super ( ) ;

}20

public User saveUser ( User u) throws SaveException {i f ( ! u . getPassword ( ) . equa l s (u . getPasswordcheck ( ) ) )

throw new SaveException ( ”Retype password” ) ;

Ent i tyTransact ion t = getNewTransaction ( ) ;

t . begin ( ) ;

i f (u . getUserId ( ) == 0)

em. p e r s i s t (u) ;

else

em. merge (u) ;

30 em. f l u s h ( ) ;

t . commit ( ) ;

return u ;

}

public User searchByUsername ( St r ing usr ) throws NoResultException {Query q = em. createQuery ( ”SELECT u FROM User u WHERE u . user = : user ” ) ;

q . setParameter ( ” user ” , usr ) ;

return ( User ) q . g e t S i n g l e R e s u l t ( ) ;

}40

public List<User> viewAl l ( ) {Query q = em. createQuery ( ”SELECT u FROM User u” ) ;

return ( L i s t<User>) q . g e t R e s u l t L i s t ( ) ;

}

public stat ic Role getRoleForPro jec t ( User u , Agreement p) {i f (u == null | | p == null )

293

Page 312: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return null ;

for ( Assignment a : u . getAssignments ( ) ) {50 i f ( a . g e tPro j e c t ( ) . g e tPro j e c t Id ( ) == p . g e tPro j e c t Id ( ) )

return a . getRole ( ) ;

}return null ;

}}

D.5 Package it.uniroma2.norge.model.jpa

D.5.1 Classe Agreement.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import java . u t i l . Date ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . Column ;

import javax . p e r s i s t e n c e . Entity ;

import javax . p e r s i s t e n c e . GeneratedValue ;

10 import javax . p e r s i s t e n c e . GenerationType ;

import javax . p e r s i s t e n c e . Id ;

import javax . p e r s i s t e n c e . JoinColumn ;

import javax . p e r s i s t e n c e . ManyToOne ;

import javax . p e r s i s t e n c e . OneToMany ;

import javax . p e r s i s t e n c e . Table ;

import javax . p e r s i s t e n c e . Temporal ;

import javax . p e r s i s t e n c e . TemporalType ;

@Entity

20 @Table (name = ” p r o j e c t ” )

public class Agreement implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

@Column(name = ”PROJECT ID” )

private int p r o j e c t I d ;

@Column(name = ”NAME” )

30 private St r ing name ;

@OneToMany(mappedBy = ” p r o j e c t ” )

private List<AnswerSet> answerSets ;

@OneToMany(mappedBy = ” p r o j e c t ” )

private List<Assignment> ass ignments ;

@ManyToOne

@JoinColumn (name = ”QUESTIONNAIRE ID” )

294

Page 313: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

40 private Quest ionna i re q u e s t i o n n a i r e ;

@Column(name = ”PDF SUPPLIER DATE” )

@Temporal ( TemporalType .TIMESTAMP)

private Date pdfSuppl ierDate ;

@Column(name = ”PDF CERTIFIER DATE” )

@Temporal ( TemporalType .TIMESTAMP)

private Date p d f C e r t i f i e r D a t e ;

50 @Column(name = ”PDF STATUS” )

private St r ing pdfStatus ;

@OneToMany(mappedBy=” p r o j e c t ” )

private List<Document> documents ;

@Column(name=”DELIVERABLES STATUS” )

private St r ing d e l i v e r a b l e s S t a t u s ;

@Column(name = ”DELIVERABLES COMMENT” )

60 private St r ing del iverablesComment ;

@OneToMany(mappedBy=” p r o j e c t ” )

private List<Del ive rab l e> d e l i v e r a b l e s ;

@ManyToOne

@JoinColumn (name=” o r g s u p p l i e r i d ” )

private Organizat ion o r g a n i z a t i o n S u p p l i e r ;

@ManyToOne

70 @JoinColumn (name=” o r g c e r t i f i e r i d ” )

private Organizat ion o r g a n i z a t i o n C e r t i f i e r ;

public Agreement ( ) {}

public int ge tPro j e c t Id ( ) {return this . p r o j e c t I d ;

}80

public void s e t P r o j e c t I d ( int p r o j e c t I d ) {this . p r o j e c t I d = p r o j e c t I d ;

}

public St r ing getName ( ) {return this . name ;

}

public void setName ( St r ing name) {90 this . name = name ;

}

public List<AnswerSet> getAnswerSets ( ) {return this . answerSets ;

}

295

Page 314: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void setAnswerSets ( L i s t<AnswerSet> answerSets ) {this . answerSets = answerSets ;

}100

public List<Assignment> getAssignments ( ) {return this . ass ignments ;

}

public void setAss ignments ( L is t<Assignment> ass ignments ) {this . ass ignments = ass ignments ;

}

public Quest ionna i re ge tQues t i onna i r e ( ) {110 return this . q u e s t i o n n a i r e ;

}

public void s e tQue s t i onna i r e ( Quest ionna i re q u e s t i o n n a i r e ) {this . q u e s t i o n n a i r e = q u e s t i o n n a i r e ;

}

@Override

public int hashCode ( ) {f ina l int prime = 31 ;

120 int r e s u l t = 1 ;

r e s u l t = prime ∗ r e s u l t + ( ( name == null ) ? 0 : name . hashCode ( ) ) ;

r e s u l t = prime ∗ r e s u l t + p r o j e c t I d ;

return r e s u l t ;

}

@Override

public boolean equa l s ( Object obj ) {i f ( this == obj ) {

return true ;

130 }i f ( obj == null ) {

return fa l se ;

}i f ( ! ( obj instanceof Agreement ) ) {

return fa l se ;

}Agreement other = ( Agreement ) obj ;

i f (name == null ) {i f ( other . name != null ) {

140 return fa l se ;

}} else i f ( ! name . equa l s ( other . name) ) {

return fa l se ;

}i f ( p r o j e c t I d != other . p r o j e c t I d ) {

return fa l se ;

}return true ;

}150

public St r ing toS t r i ng ( ) {

296

Page 315: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return name ;

}

public Date getPdfSuppl ierDate ( ) {return pdfSuppl ierDate ;

}

public void se tPdfSuppl i e rDate ( Date pdfSuppl ierDate ) {160 this . pdfSuppl ie rDate = pdfSuppl ierDate ;

}

public Date g e t P d f C e r t i f i e r D a t e ( ) {return p d f C e r t i f i e r D a t e ;

}

public void s e t P d f C e r t i f i e r D a t e ( Date p d f C e r t i f i e r D a t e ) {this . p d f C e r t i f i e r D a t e = p d f C e r t i f i e r D a t e ;

170 }

public void s e tPdfStatus ( S t r ing pdfStatus ) {this . pd fStatus = pdfStatus ;

}

public St r ing getPdfStatus ( ) {return pdfStatus ;

}

180 public List<Document> getDocuments ( ) {return this . documents ;

}

public void setDocuments ( L is t<Document> documents ) {this . documents = documents ;

}

public St r ing g e t D e l i v e r a b l e s S t a t u s ( ) {return d e l i v e r a b l e s S t a t u s ;

190 }

public void s e t D e l i v e r a b l e s S t a t u s ( S t r ing d e l i v e r a b l e s S t a t u s ) {this . d e l i v e r a b l e s S t a t u s = d e l i v e r a b l e s S t a t u s ;

}

public List<Del ive rab l e> g e t D e l i v e r a b l e s ( ) {return d e l i v e r a b l e s ;

}

200 public void s e t D e l i v e r a b l e s ( L i s t<Del ive rab l e> d e l i v e r a b l e s ) {this . d e l i v e r a b l e s = d e l i v e r a b l e s ;

}

public St r ing getDeliverablesComment ( ) {return del iverablesComment ;

}

297

Page 316: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void setDel iverablesComment ( S t r ing del iverablesComment ) {this . del iverablesComment = del iverablesComment ;

210 }

public void s e tOrgan i za t i onSupp l i e r ( Organizat ion o r g a n i z a t i o n S u p p l i e r ) {this . o r g a n i z a t i o n S u p p l i e r = o r g a n i z a t i o n S u p p l i e r ;

}

public Organizat ion ge tOrgan i za t i onSupp l i e r ( ) {return o r g a n i z a t i o n S u p p l i e r ;

}

220 public void s e t O r g a n i z a t i o n C e r t i f i e r ( Organizat ion o r g a n i z a t i o n C e r t i f i e r ) {this . o r g a n i z a t i o n C e r t i f i e r = o r g a n i z a t i o n C e r t i f i e r ;

}

public Organizat ion g e t O r g a n i z a t i o n C e r t i f i e r ( ) {return o r g a n i z a t i o n C e r t i f i e r ;

}

}

D.5.2 Classe AlternativeAnswer.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . Column ;

import javax . p e r s i s t e n c e . Entity ;

import javax . p e r s i s t e n c e . FetchType ;

import javax . p e r s i s t e n c e . GeneratedValue ;

10 import javax . p e r s i s t e n c e . GenerationType ;

import javax . p e r s i s t e n c e . Id ;

import javax . p e r s i s t e n c e . JoinColumn ;

import javax . p e r s i s t e n c e . Lob ;

import javax . p e r s i s t e n c e . ManyToOne ;

import javax . p e r s i s t e n c e . OneToMany ;

import javax . p e r s i s t e n c e . Table ;

import javax . p e r s i s t e n c e . Trans ient ;

@Entity

20 @Table (name = ” a l t e r n a t i v e a n s w e r ” )

public class Alternat iveAnswer implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

public stat ic f ina l I n t e g e r MinSi lLeve l = 0 ;

public stat ic f ina l I n t e g e r MaxSilLevel = 5 ;

public stat ic class S i l L e v e l s {public stat ic f ina l St r ing ALWAYS = ”Always” , L1 = ”1” , L2 = ”2” ,

L3 = ”3” , L4 = ”4” , NEVER = ”Never” ;

30 }

298

Page 317: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

@Column(name = ”ANSWER ID” )

private int answerId ;

@Lob( )

@Column(name = ”ANSWER” )

private St r ing answer ;

40@Column(name = ”ANSWER CODE” )

private St r ing answerCode ;

@ManyToOne

@JoinColumn (name = ”QUESTION ID” )

private Question ques t i on ;

@OneToMany(mappedBy = ” a l te rnat iveAnswer ” )

private List<Evidence> answsetAnsws ;

50@OneToMany(mappedBy = ” al ternat iveAnswerTarget ” , f e t c h = FetchType .EAGER)

private List<RuleExclusion> ru l eExc lu s i onsTarge t ;

@OneToMany(mappedBy = ” a l te rnat iveAnswerSource ” , f e t c h = FetchType .EAGER)

private List<RuleExclusion> ru l eExc lu s i on sSour c e ;

@OneToMany(mappedBy = ” a l te rnat iveAnswer ” , f e t c h = FetchType .EAGER)

private List<RuleMul tep l i c i ty> r u l e M u l t e p l i c i t i e s ;

60 @ManyToOne

@JoinColumn (name = ”FATHER ANSWER ID” )

private Alternat iveAnswer f a t h e r A l t e r n a t i v e ;

@OneToMany(mappedBy = ” f a t h e r A l t e r n a t i v e ” )

private List<AlternativeAnswer> s onA l t e rna t i v e s ;

@Column(name = ”SIL MIN LEVEL” )

private I n t e g e r s i lMinLeve l ;

70 @Transient

private St r ing s i l M i n L e v e l S t r i n g ;

public Alternat iveAnswer ( ) {}

public int getAnswerId ( ) {return this . answerId ;

}

80 public void setAnswerId ( int answerId ) {this . answerId = answerId ;

}

public St r ing getAnswer ( ) {return this . answer ;

}

299

Page 318: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void setAnswer ( S t r ing answer ) {this . answer = answer ;

90 }

public St r ing getAnswerCode ( ) {return this . answerCode ;

}

public void setAnswerCode ( St r ing answerCode ) {this . answerCode = answerCode ;

}

100 public Question getQuest ion ( ) {return this . que s t i on ;

}

public void se tQuest ion ( Question ques t i on ) {this . ques t i on = ques t i on ;

}

public List<Evidence> getAnswsetAnsws ( ) {return this . answsetAnsws ;

110 }

public void setAnswsetAnsws ( Lis t<Evidence> answsetAnsws ) {this . answsetAnsws = answsetAnsws ;

}

public List<RuleExclusion> getRuleExc lus ionsTarget ( ) {return this . ru l eExc lu s i onsTarge t ;

}

120 public void se tRuleExc lus ionsTarget ( L is t<RuleExclusion> ru l eExc lu s i onsTarge t ) {this . ru l eExc lu s i onsTarge t = ru l eExc lu s i onsTarge t ;

}

public List<RuleExclusion> getRuleExc lus ionsSource ( ) {return this . r u l eExc lu s i on sSour c e ;

}

public void s e tRu leExc lus ionsSource ( Lis t<RuleExclusion> ru l eExc lu s i on sSourc e ) {this . r u l eExc lu s i on sSour c e = ru l eExc lu s i on sSourc e ;

130 }

public List<RuleMul tep l i c i ty> g e t R u l e M u l t e p l i c i t i e s ( ) {return this . r u l e M u l t e p l i c i t i e s ;

}

public void s e t R u l e M u l t e p l i c i t i e s ( L i s t<RuleMul tep l i c i ty> r u l e M u l t e p l i c i t i e s ) {this . r u l e M u l t e p l i c i t i e s = r u l e M u l t e p l i c i t i e s ;

}

140 @Override

public int hashCode ( ) {f ina l int prime = 31 ;

300

Page 319: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

int r e s u l t = 1 ;

r e s u l t = prime ∗ r e s u l t + ( ( answer == null ) ? 0 : answer . hashCode ( ) ) ;

r e s u l t = prime ∗ r e s u l t

+ ( ( answerCode == null ) ? 0 : answerCode . hashCode ( ) ) ;

r e s u l t = prime ∗ r e s u l t + answerId ;

return r e s u l t ;

}150

@Override

public boolean equa l s ( Object obj ) {i f ( this == obj ) {

return true ;

}i f ( obj == null ) {

return fa l se ;

}i f ( ! ( obj instanceof Alternat iveAnswer ) ) {

160 return fa l se ;

}Alternat iveAnswer other = ( Alternat iveAnswer ) obj ;

i f ( answer == null ) {i f ( other . answer != null ) {

return fa l se ;

}} else i f ( ! answer . equa l s ( other . answer ) ) {

return fa l se ;

}170 i f ( answerCode == null ) {

i f ( other . answerCode != null ) {return fa l se ;

}} else i f ( ! answerCode . equa l s ( other . answerCode ) ) {

return fa l se ;

}i f ( answerId != other . answerId ) {

return fa l se ;

}180 return true ;

}

public St r ing toS t r i ng ( ) {return answer ;

}

public void s e tS i lMinLeve l ( I n t e g e r s i lMinLeve l ) {i f ( s i lMinLeve l > MaxSilLevel )

s i lMinLeve l = MaxSilLevel ;

190 this . s i lMinLeve l = s i lMinLeve l ;

}

public I n t e g e r getS i lMinLeve l ( ) {i f ( s i lMinLeve l == null )

return MinSi lLeve l ;

return s i lMinLeve l ;

}

301

Page 320: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public I n t e g e r getTrueSi lMinLeve l ( ) {200 return s i lMinLeve l ;

}

public void s e t S i l M i n L e v e l S t r i n g ( S t r ing s i l M i n L e v e l S t r i n g ) {this . s i l M i n L e v e l S t r i n g = s i l M i n L e v e l S t r i n g ;

i f ( s i l M i n L e v e l S t r i n g . equa l s IgnoreCase ( S i l L e v e l s .ALWAYS)

| | s i l M i n L e v e l S t r i n g . equa l s IgnoreCase ( ”0” ) )

s e tS i lMinLeve l (0 ) ;

else i f ( s i l M i n L e v e l S t r i n g . equa l s IgnoreCase ( S i l L e v e l s . L1) )

s e tS i lMinLeve l (1 ) ;

210 else i f ( s i l M i n L e v e l S t r i n g . equa l s IgnoreCase ( S i l L e v e l s . L2) )

s e tS i lMinLeve l (2 ) ;

else i f ( s i l M i n L e v e l S t r i n g . equa l s IgnoreCase ( S i l L e v e l s . L3) )

s e tS i lMinLeve l (3 ) ;

else i f ( s i l M i n L e v e l S t r i n g . equa l s IgnoreCase ( S i l L e v e l s . L4) )

s e tS i lMinLeve l (4 ) ;

else i f ( s i l M i n L e v e l S t r i n g . equa l s IgnoreCase ( S i l L e v e l s .NEVER)

| | s i l M i n L e v e l S t r i n g . equa l s IgnoreCase ( ”5” ) )

s e tS i lMinLeve l (5 ) ;

}220

public St r ing ge tS i lMinLeve lS t r ing ( ) {I n t e g e r s = getS i lMinLeve l ( ) ;

switch ( s ) {case 0 :

s i l M i n L e v e l S t r i n g = S i l L e v e l s .ALWAYS;

break ;

case 1 :

s i l M i n L e v e l S t r i n g = S i l L e v e l s . L1 ;

break ;

230 case 2 :

s i l M i n L e v e l S t r i n g = S i l L e v e l s . L2 ;

break ;

case 3 :

s i l M i n L e v e l S t r i n g = S i l L e v e l s . L3 ;

break ;

case 4 :

s i l M i n L e v e l S t r i n g = S i l L e v e l s . L4 ;

break ;

case 5 :

240 s i l M i n L e v e l S t r i n g = S i l L e v e l s .NEVER;

break ;

}return s i l M i n L e v e l S t r i n g ;

}

public Alternat iveAnswer ge tFathe rA l t e rna t i ve ( ) {return this . f a t h e r A l t e r n a t i v e ;

}

250 public void s e tFa the rA l t e rna t i v e ( Alternat iveAnswer f a t h e r A l t e r n a t i v e ) {this . f a t h e r A l t e r n a t i v e = f a t h e r A l t e r n a t i v e ;

}

public List<AlternativeAnswer> ge tSonAl t e rna t ive s ( ) {

302

Page 321: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return this . s onA l t e rna t i v e s ;

}

public void s e tSonA l t e rna t i v e s ( Li s t<AlternativeAnswer> s onA l t e rna t i v e s ) {this . s onA l t e rna t i v e s = sonA l t e rna t i v e s ;

260 }

}

D.5.3 Classe AnswerSet.java

package i t . uniroma2 . norge . model . jpa ;

import i t . uniroma2 . norge . common . Quest ionStatus ;

import java . i o . S e r i a l i z a b l e ;

import java . u t i l . Date ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . CascadeType ;

10 import javax . p e r s i s t e n c e . Column ;

import javax . p e r s i s t e n c e . Entity ;

import javax . p e r s i s t e n c e . GeneratedValue ;

import javax . p e r s i s t e n c e . GenerationType ;

import javax . p e r s i s t e n c e . Id ;

import javax . p e r s i s t e n c e . JoinColumn ;

import javax . p e r s i s t e n c e . ManyToOne ;

import javax . p e r s i s t e n c e . OneToMany ;

import javax . p e r s i s t e n c e . Table ;

import javax . p e r s i s t e n c e . Temporal ;

20 import javax . p e r s i s t e n c e . TemporalType ;

import javax . p e r s i s t e n c e . Trans ient ;

@Entity

@Table (name = ” answer se t ” )

public class AnswerSet implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

30 @Column(name = ”ANSWER SET ID” )

private int answerSetId ;

@ManyToOne

@JoinColumn (name = ”QUESTION ID” )

private Question ques t i on ;

@ManyToOne

@JoinColumn (name = ”PROJECT ID” )

private Agreement p r o j e c t ;

40@OneToMany(mappedBy = ” answerSet ” , cascade = CascadeType .REFRESH)

private List<Evidence> answsetAnsws ;

303

Page 322: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Column(name = ”OPEN ANSWER” )

private St r ing openAnswer ;

@Temporal ( TemporalType .TIMESTAMP)

@Column(name = ”APPROV LASTMOD” )

private Date approvLastmod ;

50

@Column(name = ”APPROVATION STATUS” )

private St r ing approvat ionStatus ;

@Column(name = ”DELIV APPROVATION STATUS” )

private St r ing de l ivApprovat ionStatus ;

@Temporal ( TemporalType .TIMESTAMP)

@Column(name = ”FILL LASTMOD” )

60 private Date f i l l L a s t mod ;

@Column(name = ”APPROVATION STATUS FINAL” )

private St r ing approvat ionStatusF ina l ;

@Transient

private St r ing f i n a l S t a t u s ;

@OneToMany(mappedBy = ” answerSet ” , cascade = CascadeType .REFRESH)

private List<AnswsetHistory> a n s w s e t H i s t o r i e s ;

70@Transient

private int ranking ;

@Transient

private int p r i o r i t y ;

@Transient

private St r ing quest ionText ;

public AnswerSet ( ) {80 }

public int getAnswerSetId ( ) {return this . answerSetId ;

}

public void setAnswerSetId ( int answerSetId ) {this . answerSetId = answerSetId ;

}

90 public Question getQuest ion ( ) {return this . que s t i on ;

}

public void se tQuest ion ( Question ques t i on ) {this . ques t i on = ques t i on ;

}

public Agreement ge tPro j e c t ( ) {return this . p r o j e c t ;

304

Page 323: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

100 }

public void s e t P r o j e c t ( Agreement p r o j e c t ) {this . p r o j e c t = p r o j e c t ;

}

public List<Evidence> getAnswsetAnsws ( ) {return this . answsetAnsws ;

}

110 public void setAnswsetAnsws ( Lis t<Evidence> answsetAnsws ) {this . answsetAnsws = answsetAnsws ;

}

public void setOpenAnswer ( S t r ing openAnswer ) {this . openAnswer = openAnswer ;

}

public St r ing getOpenAnswer ( ) {return openAnswer ;

120 }

public void setApprovLastmod ( Date approvLastmod ) {this . approvLastmod = approvLastmod ;

}

public Date getApprovLastmod ( ) {return approvLastmod ;

}

130public void setApprovat ionStatus ( S t r ing approvat ionStatus ) {

this . approvat ionStatus = approvat ionStatus ;

}

public St r ing getApprovat ionStatus ( ) {return approvat ionStatus ;

}

public void s e tF i l lLas tmod ( Date f i l l L a s t mod ) {140 this . f i l l L a s t mod = f i l l La s tm od ;

}

public Date getFi l lLastmod ( ) {return f i l l La s tmo d ;

}

public void se tApprovat ionStatusF ina l ( S t r ing approvat ionStatusF ina l ) {i f ( getQuest ion ( ) . g e tRe la t i on ( ) != null )

this . f i n a l S t a t u s = approvat ionStatusF ina l ;

150 this . approvat ionStatusF ina l = approvat ionStatusF ina l ;

}

public St r ing getApprovat ionStatusFina l ( ) {return approvat ionStatusF ina l ;

}

305

Page 324: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public List<AnswsetHistory> ge tAnswse tHi s to r i e s ( ) {return this . a n s w s e t H i s t o r i e s ;

}160

public void s e tAnswse tH i s t o r i e s ( L i s t<AnswsetHistory> a n s w s e t H i s t o r i e s ) {this . a n s w s e t H i s t o r i e s = a n s w s e t H i s t o r i e s ;

}

public void setRanking ( int ranking ) {this . ranking = ranking ;

}

public int getRanking ( ) {170 return ranking ;

}

public void s e t P r i o r i t y ( int p r i o r i t y ) {this . p r i o r i t y = p r i o r i t y ;

}

public int g e t P r i o r i t y ( ) {p r i o r i t y = 0 ;

i f ( ! getApprovat ionStatusFina l ( ) . equa l s ( Quest ionStatus .ACCEPTED) )

180 for ( Alternat iveAnswer a : getQuest ion ( ) . getAlternat iveAnswers ( ) ) {p r i o r i t y += a . getRuleExc lus ionsTarget ( ) . s i z e ( ) ;

p r i o r i t y −= a . getRuleExc lus ionsSource ( ) . s i z e ( ) ;

p r i o r i t y += a . g e t R u l e M u l t e p l i c i t i e s ( ) . s i z e ( ) ;

}p r i o r i t y −= getQuest ion ( ) . g e t R u l e M u l t e p l i c i t i e s ( ) . s i z e ( ) ;

return p r i o r i t y ;

}

public void setQuest ionText ( S t r ing quest ionText ) {190 this . quest ionText = quest ionText ;

}

public St r ing getQuest ionText ( ) {quest ionText = getQuest ion ( ) . getQuest ion ( ) ;

return quest ionText ;

}

public void se tDe l ivApprovat ionStatus ( S t r ing de l ivApprovat ionStatus ) {this . de l ivApprovat ionStatus = de l ivApprovat ionStatus ;

200 }

public St r ing getDel ivApprovat ionStatus ( ) {i f ( de l ivApprovat ionStatus == null

&& getQuest ion ( ) . g e tRe la t i on ( ) == null )

return Quest ionStatus .TO SPECIFY;

return de l ivApprovat ionStatus ;

}

public void s e t F i n a l S t a t u s ( S t r ing f i n a l S t a t u s ) {210 this . f i n a l S t a t u s = f i n a l S t a t u s ;

}

306

Page 325: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public St r ing ge tF ina lS ta tu s ( ) {i f ( getQuest ion ( ) . g e tRe la t i on ( ) != null )

return getApprovat ionStatusFina l ( ) ;

return Quest ionStatus . min ( getApprovat ionStatusFina l ( ) ,

getDel ivApprovat ionStatus ( ) ) ;

}}

D.5.4 Classe AnswsetHistory.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

import java . u t i l . Date ;

@Entity

@Table (name = ” answse t h i s t o ry ” )

10 public class AnswsetHistory implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

@Column(name = ”ANSWSET HISTORY ID” )

private int answsetHis toryId ;

@Lob( )

@Column(name = ”ACTION” )

20 private St r ing ac t i on ;

@Column(name = ”COMMENT” )

private St r ing comment ;

@Temporal ( TemporalType .TIMESTAMP)

@Column(name = ”MODTIME” )

private Date modtime ;

@ManyToOne

30 @JoinColumn (name = ”USER ID” )

private User user ;

@Column(name = ”ROLE” )

private St r ing r o l e ;

@ManyToOne

@JoinColumn (name = ”ANSWER SET ID” )

private AnswerSet answerSet ;

40 public AnswsetHistory ( ) {}

public int getAnswsetHistoryId ( ) {

307

Page 326: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return this . answsetHis toryId ;

}

public void setAnswsetHistoryId ( int answsetHis toryId ) {this . answsetHis toryId = answsetHis toryId ;

}50

public St r ing getAct ion ( ) {return this . a c t i on ;

}

public void se tAct ion ( St r ing ac t i on ) {this . a c t i on = act i on ;

}

public St r ing getComment ( ) {60 return this . comment ;

}

public void setComment ( St r ing comment ) {this . comment = comment ;

}

public Date getModtime ( ) {return this . modtime ;

}70

public void setModtime ( Date modtime ) {this . modtime = modtime ;

}

public User getUser ( ) {return this . u se r ;

}

public void se tUser ( User user ) {80 this . u se r = user ;

}

public AnswerSet getAnswerSet ( ) {return this . answerSet ;

}

public void setAnswerSet ( AnswerSet answerSet ) {this . answerSet = answerSet ;

}90

public void s e tRo le ( S t r ing r o l e ) {this . r o l e = r o l e ;

}

public St r ing getRole ( ) {return r o l e ;

}

public St r ing toLongStr ing ( ) {

308

Page 327: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

100 St r ing s = ”” ;

i f ( getComment ( ) . tr im ( ) . l ength ( ) > 0)

s = ” ( ” + getComment ( ) . tr im ( ) + ” ) ” ;

return ” [ ” + getRole ( ) + ” ] ” + getAct ion ( ) . tr im ( ) + ”” + s + ”” ;

}

}

D.5.5 Classe Assignment.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

@Entity

@Table (name=” assignment ” )

public class Assignment implements S e r i a l i z a b l e {10 private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

@Column(name=”ASSIGNMENT ID” )

private int ass ignmentId ;

@ManyToOne

@JoinColumn (name=”PROJECT ID” )

private Agreement p r o j e c t ;

20@ManyToOne

@JoinColumn (name=”USER ID” )

private User user ;

@ManyToOne

@JoinColumn (name=”ROLE ID” )

private Role r o l e ;

public Assignment ( ) {30 }

public int getAssignmentId ( ) {return this . ass ignmentId ;

}

public void setAss ignmentId ( int ass ignmentId ) {this . ass ignmentId = ass ignmentId ;

}

40 public Agreement ge tPro j e c t ( ) {return this . p r o j e c t ;

}

public void s e t P r o j e c t ( Agreement p r o j e c t ) {

309

Page 328: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

this . p r o j e c t = p r o j e c t ;

}

public User getUser ( ) {return this . u se r ;

50 }

public void se tUser ( User user ) {this . u se r = user ;

}

public Role getRole ( ) {return this . r o l e ;

}

60 public void s e tRo le ( Role r o l e ) {this . r o l e = r o l e ;

}

}

D.5.6 Classe DefaultDeliverable.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . CascadeType ;

import javax . p e r s i s t e n c e . Column ;

import javax . p e r s i s t e n c e . Entity ;

import javax . p e r s i s t e n c e . GeneratedValue ;

import javax . p e r s i s t e n c e . GenerationType ;

10 import javax . p e r s i s t e n c e . Id ;

import javax . p e r s i s t e n c e . JoinColumn ;

import javax . p e r s i s t e n c e . ManyToOne ;

import javax . p e r s i s t e n c e . Table ;

import javax . p e r s i s t e n c e . Trans ient ;

import org . e c l i p s e . p e r s i s t e n c e . annotat ions . Cache ;

import org . e c l i p s e . p e r s i s t e n c e . annotat ions . CacheType ;

@Entity

20 @Cache( type = CacheType .NONE, exp i ry = 0 , a lwaysRefresh = true )

@Table (name = ” d e l i v e r a b l e d e f a u l t ” )

public class D e f a u l t D e l i v e r a b l e implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

@Column(name = ”DELIVERABLE ID” )

private int d e l i v e r a b l e I d ;

30 @Column(name = ”NAME” )

private St r ing name ;

310

Page 329: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Column(name = ”DESCRIPTION” )

private St r ing d e s c r i p t i o n ;

@Column(name = ”TYPE” )

private St r ing type ;

@Column(name = ”SUBTYPE1” )

40 private St r ing subtype1 ;

@Column(name = ”SUBTYPE2” )

private St r ing subtype2 ;

@ManyToOne( cascade = CascadeType .REFRESH)

@JoinColumn (name = ” d e l i v s u b c a t e g i d ” )

private Del ivSubcateg de l ivSubcateg ;

@Transient

50 private DelivCateg de l ivCateg ;

public D e f a u l t D e l i v e r a b l e ( ) {}

public int g e t D e l i v e r a b l e I d ( ) {return this . d e l i v e r a b l e I d ;

}

public void s e t D e l i v e r a b l e I d ( int d e l i v e r a b l e I d ) {60 this . d e l i v e r a b l e I d = d e l i v e r a b l e I d ;

}

public St r ing getName ( ) {return this . name ;

}

public void setName ( St r ing name) {this . name = name ;

}70

public St r ing toS t r i ng ( ) {return name ;

}

public St r ing getType ( ) {return type ;

}

public void setType ( S t r ing type ) {80 this . type = type ;

}

public St r ing getSubtype1 ( ) {return subtype1 ;

}

public void setSubtype1 ( S t r ing subtype1 ) {

311

Page 330: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

this . subtype1 = subtype1 ;

}90

public St r ing getSubtype2 ( ) {return subtype2 ;

}

public void setSubtype2 ( S t r ing subtype2 ) {this . subtype2 = subtype2 ;

}

public void s e t D e s c r i p t i o n ( S t r ing d e s c r i p t i o n ) {100 this . d e s c r i p t i o n = d e s c r i p t i o n ;

}

public St r ing ge tDe s c r i p t i on ( ) {return d e s c r i p t i o n ;

}

public Del ivSubcateg getDel ivSubcateg ( ) {return de l ivSubcateg ;

}110

public void s e tDe l ivSubcateg ( Del ivSubcateg de l ivSubcateg ) {this . de l i vSubcateg = de l ivSubcateg ;

this . de l ivCateg = de l ivSubcateg . getDel ivCateg ( ) ;

}

public void se tDe l ivCateg ( Del ivCateg de l ivCateg ) {this . de l ivCateg = de l ivCateg ;

}

120 public DelivCateg getDel ivCateg ( ) {i f ( de l ivCateg != null )

return de l ivCateg ;

i f ( de l ivSubcateg != null )

return de l ivSubcateg . getDel ivCateg ( ) ;

return null ;

}}

D.5.7 Classe DelivCateg.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

import java . u t i l . L i s t ;

@Entity

10 @Table (name=” d e l i v c a t e g ” )

public class DelivCateg implements S e r i a l i z a b l e {

312

Page 331: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

@Column(name=” d e l i v c a t e g i d ” )

private int de l ivCateg Id ;

private St r ing code ;

20private St r ing name ;

@OneToMany(mappedBy=” de l ivCateg ” , cascade=CascadeType .REFRESH)

private List<DelivSubcateg> de l i vSubcateg s ;

public DelivCateg ( ) {}

public int getDel ivCategId ( ) {30 return this . de l i vCateg Id ;

}

public void se tDe l ivCategId ( int de l ivCateg Id ) {this . de l i vCateg Id = de l ivCateg Id ;

}

public St r ing getCode ( ) {return this . code ;

}40

public void setCode ( S t r ing code ) {this . code = code ;

}

public St r ing getName ( ) {return this . name ;

}

public void setName ( St r ing name) {50 this . name = name ;

}

public List<DelivSubcateg> getDe l ivSubcategs ( ) {return this . d e l i vSubcateg s ;

}

public void s e tDe l i vSubcategs ( L is t<DelivSubcateg> de l i vSubcateg s ) {this . d e l i vSubcateg s = de l i vSubcateg s ;

}60

@Override

public St r ing toS t r i ng ( ) {return code+”/”+name ;

}

@Override

public int hashCode ( ) {

313

Page 332: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

f ina l int prime = 31 ;

int r e s u l t = 1 ;

70 r e s u l t = prime ∗ r e s u l t + ( ( code == null ) ? 0 : code . hashCode ( ) ) ;

r e s u l t = prime ∗ r e s u l t + de l ivCateg Id ;

r e s u l t = prime ∗ r e s u l t + ( ( name == null ) ? 0 : name . hashCode ( ) ) ;

return r e s u l t ;

}

@Override

public boolean equa l s ( Object obj ) {i f ( this == obj )

return true ;

80 i f ( obj == null )

return fa l se ;

i f ( ge tC la s s ( ) != obj . g e tC la s s ( ) )

return fa l se ;

Del ivCateg other = ( Del ivCateg ) obj ;

i f ( code == null ) {i f ( other . code != null )

return fa l se ;

} else i f ( ! code . equa l s ( other . code ) )

return fa l se ;

90 i f ( de l ivCateg Id != other . de l ivCateg Id )

return fa l se ;

i f (name == null ) {i f ( other . name != null )

return fa l se ;

} else i f ( ! name . equa l s ( other . name) )

return fa l se ;

return true ;

}

100 }

D.5.8 Classe Deliverable.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import java . u t i l . ArrayList ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . Column ;

import javax . p e r s i s t e n c e . Entity ;

import javax . p e r s i s t e n c e . GeneratedValue ;

10 import javax . p e r s i s t e n c e . GenerationType ;

import javax . p e r s i s t e n c e . Id ;

import javax . p e r s i s t e n c e . JoinColumn ;

import javax . p e r s i s t e n c e . ManyToOne ;

import javax . p e r s i s t e n c e . OneToMany ;

import javax . p e r s i s t e n c e . Table ;

import javax . p e r s i s t e n c e . Trans ient ;

@Entity

314

Page 333: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Table (name = ” d e l i v e r a b l e ” )

20 public class D e l i v e r a b l e implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

@Column(name = ”DELIVERABLE ID” )

private int d e l i v e r a b l e I d ;

@Column(name = ”APPROVAL STATUS” )

private St r ing approva lStatus ;

30@Column(name = ”NAME” )

private St r ing name ;

@Column(name = ”DESCRIPTION” )

private St r ing d e s c r i p t i o n ;

@ManyToOne

@JoinColumn (name = ”PROJECT ID” )

private Agreement p r o j e c t ;

40@OneToMany(mappedBy = ” d e l i v e r a b l e ” )

private List<Del iverab leEvidence> d e l i v e r a b l e E v i d e n c e s ;

@OneToMany(mappedBy = ” d e l i v e r a b l e ” )

private List<De l i v e rab l eH i s to ry> d e l i v e r a b l e H i s t o r i e s ;

@Column(name = ”TYPE” )

private St r ing type ;

50 @Column(name = ”SUBTYPE1” )

private St r ing subtype1 ;

@Column(name = ”SUBTYPE2” )

private St r ing subtype2 ;

@ManyToOne

@JoinColumn (name = ” d e l i v s u b c a t e g i d ” )

private Del ivSubcateg de l ivSubcateg ;

60 @Transient

private DelivCateg de l ivCateg ;

public D e l i v e r a b l e ( ) {}

public int g e t D e l i v e r a b l e I d ( ) {return this . d e l i v e r a b l e I d ;

}

70 public void s e t D e l i v e r a b l e I d ( int d e l i v e r a b l e I d ) {this . d e l i v e r a b l e I d = d e l i v e r a b l e I d ;

}

public St r ing getApprovalStatus ( ) {

315

Page 334: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return this . approva lStatus ;

}

public void setApprova lStatus ( S t r ing approva lStatus ) {this . approva lStatus = approva lStatus ;

80 }

public St r ing getName ( ) {return this . name ;

}

public void setName ( St r ing name) {this . name = name ;

}

90 public Agreement ge tPro j e c t ( ) {return this . p r o j e c t ;

}

public void s e t P r o j e c t ( Agreement p r o j e c t ) {this . p r o j e c t = p r o j e c t ;

}

public List<Del iverab leEvidence> ge tDe l i v e rab l eEv idence s ( ) {return this . d e l i v e r a b l e E v i d e n c e s ;

100 }

public void s e t D e l i v e r a b l e E v i d e n c e s (

Li s t<Del iverab leEvidence> d e l i v e r a b l e E v i d e n c e s ) {this . d e l i v e r a b l e E v i d e n c e s = d e l i v e r a b l e E v i d e n c e s ;

}

public List<De l i v e rab l eH i s to ry> g e t D e l i v e r a b l e H i s t o r i e s ( ) {return this . d e l i v e r a b l e H i s t o r i e s ;

}110

public void s e t D e l i v e r a b l e H i s t o r i e s (

L i s t<De l iv e rab l eH i s to ry> d e l i v e r a b l e H i s t o r i e s ) {this . d e l i v e r a b l e H i s t o r i e s = d e l i v e r a b l e H i s t o r i e s ;

}

public int getMappedItemsNum ( ) {int r e s = 0 ;

Li s t<Del iverab leEvidence> d = ge tDe l i v e rab l eEv idence s ( ) ;

i f (d == null | | d . s i z e ( ) == 0)

120 return 0 ;

for ( De l ive rab l eEv idence de : d) {i f ( de . ge t Inc luded ( ) )

r e s++;

}return r e s ;

}

public List<Del iverab leEvidence> ge t Inc ludedDe l i v e rab l eEv idence s ( ) {List<Del iverab leEvidence> r e s = new ArrayList<Del iverab leEvidence >() ;

130 List<Del iverab leEvidence> d = ge tDe l i v e rab l eEv idence s ( ) ;

316

Page 335: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

i f (d == null | | d . s i z e ( ) == 0)

return null ;

for ( De l ive rab l eEv idence de : d) {i f ( de . ge t Inc luded ( ) )

r e s . add ( de ) ;

}return r e s ;

}

140 public St r ing toS t r i ng ( ) {return name ;

}

public void setType ( S t r ing type ) {this . type = type ;

}

public St r ing getType ( ) {return type ;

150 }

public void setSubtype1 ( S t r ing subtype1 ) {this . subtype1 = subtype1 ;

}

public St r ing getSubtype1 ( ) {return subtype1 ;

}

160 public void setSubtype2 ( S t r ing subtype2 ) {this . subtype2 = subtype2 ;

}

public St r ing getSubtype2 ( ) {return subtype2 ;

}

public void s e t D e s c r i p t i o n ( S t r ing d e s c r i p t i o n ) {this . d e s c r i p t i o n = d e s c r i p t i o n ;

170 }

public St r ing ge tDe s c r i p t i on ( ) {return d e s c r i p t i o n ;

}

@Override

public int hashCode ( ) {f ina l int prime = 31 ;

int r e s u l t = 1 ;

180 r e s u l t = prime ∗ r e s u l t + d e l i v e r a b l e I d ;

return r e s u l t ;

}

@Override

public boolean equa l s ( Object obj ) {i f ( this == obj ) {

317

Page 336: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return true ;

}i f ( obj == null ) {

190 return fa l se ;

}i f ( ! ( obj instanceof D e l i v e r a b l e ) ) {

return fa l se ;

}D e l i v e r a b l e other = ( D e l i v e r a b l e ) obj ;

i f ( d e l i v e r a b l e I d != other . d e l i v e r a b l e I d ) {return fa l se ;

}return true ;

200 }

public Del ivSubcateg getDel ivSubcateg ( ) {return de l ivSubcateg ;

}

public void s e tDe l ivSubcateg ( Del ivSubcateg de l ivSubcateg ) {this . de l i vSubcateg = de l ivSubcateg ;

this . de l ivCateg = de l ivSubcateg . getDel ivCateg ( ) ;

}210

public void se tDe l ivCateg ( Del ivCateg de l ivCateg ) {this . de l ivCateg = de l ivCateg ;

}

public DelivCateg getDel ivCateg ( ) {i f ( de l ivCateg != null )

return de l ivCateg ;

i f ( de l ivSubcateg != null )

return de l ivSubcateg . getDel ivCateg ( ) ;

220 return null ;

}}

D.5.9 Classe DeliverableContentHistory.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

import java . u t i l . Date ;

@Entity

10 @Table (name=” answse t an sw de l i vh i s t o ry ” )

public class Del ive rab l eContentHi s to ry implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

318

Page 337: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Column(name=”ANSWSET ANSW DELIVHISTORY ID” )

private int answsetHis toryId ;

@Lob( )

20 @Column(name=”ACTION” )

private St r ing ac t i on ;

@Column(name=”COMMENT” )

private St r ing comment ;

@Temporal ( TemporalType .TIMESTAMP)

@Column(name=”MODTIME” )

private Date modtime ;

30 @ManyToOne

@JoinColumn (name=”USER ID” )

private User user ;

@Column(name=”ROLE” )

private St r ing r o l e ;

@ManyToOne

@JoinColumn (name=”ANSWSET ANSW ID” )

private Evidence answsetAnsw ;

40public Del ive rab l eContentHi s to ry ( ) {}

public int getAnswsetHistoryId ( ) {return this . answsetHis toryId ;

}

public void setAnswsetHistoryId ( int answsetHis toryId ) {this . answsetHis toryId = answsetHis toryId ;

50 }

public St r ing getAct ion ( ) {return this . a c t i on ;

}

public void se tAct ion ( St r ing ac t i on ) {this . a c t i on = act i on ;

}

60 public St r ing getComment ( ) {return this . comment ;

}

public void setComment ( St r ing comment ) {this . comment = comment ;

}

public Date getModtime ( ) {return this . modtime ;

70 }

319

Page 338: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void setModtime ( Date modtime ) {this . modtime = modtime ;

}

public User getUser ( ) {return this . u se r ;

}

80 public void se tUser ( User user ) {this . u se r = user ;

}

public void s e tRo le ( S t r ing r o l e ) {this . r o l e = r o l e ;

}

public St r ing getRole ( ) {return r o l e ;

90 }

public void setAnswsetAnsw ( Evidence answsetAnsw ) {this . answsetAnsw = answsetAnsw ;

}

public Evidence getAnswsetAnsw ( ) {return answsetAnsw ;

}

100 public St r ing toLongStr ing ( ) {return ” [ ”+getRole ( )+” ] ”+getAct ion ( )+” ( ”+getComment ( )+” ) ” ;

}

}

D.5.10 Classe DeliverableEvidence.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . Column ;

import javax . p e r s i s t e n c e . Entity ;

import javax . p e r s i s t e n c e . GeneratedValue ;

import javax . p e r s i s t e n c e . GenerationType ;

import javax . p e r s i s t e n c e . Id ;

10 import javax . p e r s i s t e n c e . JoinColumn ;

import javax . p e r s i s t e n c e . ManyToOne ;

import javax . p e r s i s t e n c e . Table ;

@Entity

@Table (name = ” d e l i v e r a b l e e v i d e n c e ” )

public class Del ive rab l eEv idence implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

320

Page 339: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Id

20 @GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

@Column(name = ”DELIVERABLE EVIDENCE ID” )

private int d e l i v e r a b l e E v id e n c e I d ;

@Column(name = ”INCLUDED” )

private Boolean inc luded ;

@ManyToOne

@JoinColumn (name = ”ANSWSET ANSw ID” )

private Evidence answsetAnsw ;

30@ManyToOne

@JoinColumn (name = ”DELIVERABLE ID” )

private D e l i v e r a b l e d e l i v e r a b l e ;

@Column(name = ”COMMENT” )

private St r ing approvationComment ;

@Column(name = ”ADDITIONAL INFO” )

private St r ing a d d i t i o n a l I n f o ;

40public Del ive rab l eEv idence ( ) {}

public int ge tDe l i v e rab l eEv idence Id ( ) {return this . d e l i v e r a b l e E v id e n c e I d ;

}

public void s e tDe l i v e rab l eEv idence Id ( int d e l i v e r a b l e E v id e n c e I d ) {this . d e l i v e r a b l eE v i de n c e I d = de l i v e r a b l e E v i d e nc e I d ;

50 }

public Boolean get Inc luded ( ) {return this . i nc luded ;

}

public void s e t Inc luded ( Boolean inc luded ) {i f ( inc luded == null ) {

this . i nc luded = fa l se ;

return ;

60 }this . i nc luded = inc luded ;

}

public Evidence getAnswsetAnsw ( ) {return this . answsetAnsw ;

}

public void setAnswsetAnsw ( Evidence answsetAnsw ) {this . answsetAnsw = answsetAnsw ;

70 }

public D e l i v e r a b l e g e t D e l i v e r a b l e ( ) {return this . d e l i v e r a b l e ;

}

321

Page 340: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void s e t D e l i v e r a b l e ( D e l i v e r a b l e d e l i v e r a b l e ) {this . d e l i v e r a b l e = d e l i v e r a b l e ;

}

80 public St r ing getApprovationComment ( ) {return approvationComment ;

}

public void setApprovationComment ( S t r ing approvationComment ) {i f ( approvationComment == null )

approvationComment = ”” ;

this . approvationComment = approvationComment ;

}

90 public void s e t A d d i t i o n a l I n f o ( S t r ing a d d i t i o n a l I n f o ) {this . a d d i t i o n a l I n f o = a d d i t i o n a l I n f o ;

}

public St r ing g e t A d d i t i o n a l I n f o ( ) {return a d d i t i o n a l I n f o ;

}

}

D.5.11 Classe DeliverableHistory.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

import java . u t i l . Date ;

@Entity

@Table (name=” d e l i v e r a b l e h i s t o r y ” )

10 public class D e l i v e r a b l e H i s t o r y implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

@Column(name=”DELIVERABLE HISTORY ID” )

private int d e l i v e r a b l e H i s t o r y I d ;

@Column(name=”ACTION” )

private St r ing ac t i on ;

20@Column(name=”COMMENT” )

private St r ing comment ;

@Temporal ( TemporalType .TIMESTAMP)

@Column(name=”MODTIME” )

private Date modtime ;

322

Page 341: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Column(name=”NEW STATE” )

private St r ing newState ;

30@Column(name=”ROLE” )

private St r ing r o l e ;

@ManyToOne

@JoinColumn (name=”DELIVERABLE ID” )

private D e l i v e r a b l e d e l i v e r a b l e ;

@ManyToOne

@JoinColumn (name=”USER ID” )

40 private User user ;

public D e l i v e r a b l e H i s t o r y ( ) {}

public int g e t D e l i v e r a b l e H i s t o r y I d ( ) {return this . d e l i v e r a b l e H i s t o r y I d ;

}

public void s e t D e l i v e r a b l e H i s t o r y I d ( int d e l i v e r a b l e H i s t o r y I d ) {50 this . d e l i v e r a b l e H i s t o r y I d = d e l i v e r a b l e H i s t o r y I d ;

}

public St r ing getAct ion ( ) {return this . a c t i on ;

}

public void se tAct ion ( St r ing ac t i on ) {this . a c t i on = act i on ;

}60

public St r ing getComment ( ) {return this . comment ;

}

public void setComment ( St r ing comment ) {this . comment = comment ;

}

public Date getModtime ( ) {70 return this . modtime ;

}

public void setModtime ( Date modtime ) {this . modtime = modtime ;

}

public St r ing getNewState ( ) {return this . newState ;

}80

public void setNewState ( S t r ing newState ) {this . newState = newState ;

}

323

Page 342: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public St r ing getRole ( ) {return this . r o l e ;

}

public void s e tRo le ( S t r ing r o l e ) {90 this . r o l e = r o l e ;

}

public D e l i v e r a b l e g e t D e l i v e r a b l e ( ) {return this . d e l i v e r a b l e ;

}

public void s e t D e l i v e r a b l e ( D e l i v e r a b l e d e l i v e r a b l e ) {this . d e l i v e r a b l e = d e l i v e r a b l e ;

}100

public User getUser ( ) {return this . u se r ;

}

public void se tUser ( User user ) {this . u se r = user ;

}

}

D.5.12 Classe DelivSubcateg.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . CascadeType ;

import javax . p e r s i s t e n c e . Column ;

import javax . p e r s i s t e n c e . Entity ;

import javax . p e r s i s t e n c e . GeneratedValue ;

10 import javax . p e r s i s t e n c e . GenerationType ;

import javax . p e r s i s t e n c e . Id ;

import javax . p e r s i s t e n c e . JoinColumn ;

import javax . p e r s i s t e n c e . Lob ;

import javax . p e r s i s t e n c e . ManyToOne ;

import javax . p e r s i s t e n c e . OneToMany ;

import javax . p e r s i s t e n c e . Table ;

@Entity

20 @Table (name=” d e l i v s u b c a t e g ” )

public class Del ivSubcateg implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

324

Page 343: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Column(name=” d e l i v s u b c a t e g i d ” )

private int de l ivSubcateg Id ;

@Lob( )

30 private St r ing d e s c r i p t i o n ;

private St r ing code ;

private St r ing name ;

@ManyToOne( cascade=CascadeType .REFRESH)

@JoinColumn (name=” d e l i v c a t e g i d ” )

private DelivCateg de l ivCateg ;

40 @OneToMany(mappedBy=” de l ivSubcateg ” , cascade=CascadeType .REFRESH)

private List<Del ive rab l e> d e l i v e r a b l e s ;

@OneToMany(mappedBy=” de l ivSubcateg ” , cascade=CascadeType .REFRESH)

private List<Defau l tDe l i v e rab l e> d e l i v e r a b l e D e f a u l t s ;

public Del ivSubcateg ( ) {}

public int getDe l ivSubcategId ( ) {50 return this . de l i vSubcateg Id ;

}

public void s e tDe l ivSubcateg Id ( int de l ivSubcateg Id ) {this . de l i vSubcateg Id = de l ivSubcateg Id ;

}

public St r ing ge tDe s c r i p t i on ( ) {return this . d e s c r i p t i o n ;

}60

public void s e t D e s c r i p t i o n ( S t r ing d e s c r i p t i o n ) {this . d e s c r i p t i o n = d e s c r i p t i o n ;

}

public St r ing getName ( ) {return this . name ;

}

public void setName ( St r ing name) {70 this . name = name ;

}

public DelivCateg getDel ivCateg ( ) {return this . de l ivCateg ;

}

public void se tDe l ivCateg ( Del ivCateg de l ivCateg ) {this . de l ivCateg = de l ivCateg ;

}80

public List<Defau l tDe l i v e rab l e> g e t D e l i v e r a b l e D e f a u l t s ( ) {

325

Page 344: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return this . d e l i v e r a b l e D e f a u l t s ;

}

public void s e t D e l i v e r a b l e D e f a u l t s ( L i s t<Defau l tDe l i v e rab l e> d e l i v e r a b l e D e f a u l t s )

{this . d e l i v e r a b l e D e f a u l t s = d e l i v e r a b l e D e f a u l t s ;

}

public List<Del ive rab l e> g e t D e l i v e r a b l e s ( ) {90 return d e l i v e r a b l e s ;

}

public void s e t D e l i v e r a b l e s ( L i s t<Del ive rab l e> d e l i v e r a b l e s ) {this . d e l i v e r a b l e s = d e l i v e r a b l e s ;

}

public St r ing getCode ( ) {return code ;

}100

public void setCode ( S t r ing code ) {this . code = code ;

}

@Override

public St r ing toS t r i ng ( ) {return code+”/”+name ;

}

110 @Override

public int hashCode ( ) {f ina l int prime = 31 ;

int r e s u l t = 1 ;

r e s u l t = prime ∗ r e s u l t + ( ( code == null ) ? 0 : code . hashCode ( ) ) ;

r e s u l t = prime ∗ r e s u l t + de l ivSubcateg Id ;

r e s u l t = prime ∗ r e s u l t + ( ( name == null ) ? 0 : name . hashCode ( ) ) ;

return r e s u l t ;

}

120 @Override

public boolean equa l s ( Object obj ) {i f ( this == obj )

return true ;

i f ( obj == null )

return fa l se ;

i f ( ge tC la s s ( ) != obj . g e tC la s s ( ) )

return fa l se ;

Del ivSubcateg other = ( Del ivSubcateg ) obj ;

i f ( code == null ) {130 i f ( other . code != null )

return fa l se ;

} else i f ( ! code . equa l s ( other . code ) )

return fa l se ;

i f ( de l i vSubcateg Id != other . de l i vSubcateg Id )

return fa l se ;

i f (name == null ) {

326

Page 345: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

i f ( other . name != null )

return fa l se ;

} else i f ( ! name . equa l s ( other . name) )

140 return fa l se ;

return true ;

}

}

D.5.13 Classe DiagChildren.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

import java . u t i l . L i s t ;

@Entity

@Table (name=” d i a g c h i l d r e n ” )

10 public class DiagChi ldren implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

@Column(name=”CHILDREN ID” )

private int c h i l d r e n I d ;

@Column(name=”HEIGHT” )

private int he ight ;

20@Column(name=”HREF” )

private St r ing h r e f ;

@Column(name=”IDENT” )

private St r ing ident ;

@Column(name=”TYPE” )

private int type ;

30 @Column(name=”WIDTH” )

private int width ;

@Column(name=”XPOS” )

private int xpos ;

@Column(name=”YPOS” )

private int ypos ;

@OneToMany(mappedBy=” diagChi ldrenSource ” )

40 private List<DiagEdge> diagEdgesSource ;

@OneToMany(mappedBy=” diagChi ldrenTarget ” )

private List<DiagEdge> diagEdgesTarget ;

327

Page 346: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@OneToMany(mappedBy=” diagChi ldren ” )

private List<Mclass> mclasse s ;

@OneToMany(mappedBy=” diagChi ldren ” )

private List<Mpackage> mpackages ;

50public DiagChi ldren ( ) {}

public int getCh i ldrenId ( ) {return this . c h i l d r e n I d ;

}

public void s e tCh i ld r en Id ( int c h i l d r e n I d ) {this . c h i l d r e n I d = c h i l d r e n I d ;

60 }

public int getHeight ( ) {return this . he ight ;

}

public void se tHe ight ( int he ight ) {this . he ight = he ight ;

}

70 public St r ing getHre f ( ) {return this . h r e f ;

}

public void s e tHre f ( S t r ing h r e f ) {this . h r e f = h r e f ;

}

public St r ing ge t Ident ( ) {return this . i dent ;

80 }

public void s e t I d e n t ( S t r ing ident ) {this . i d ent = ident ;

}

public int getType ( ) {return this . type ;

}

90 public void setType ( int type ) {this . type = type ;

}

public int getWidth ( ) {return this . width ;

}

public void setWidth ( int width ) {this . width = width ;

328

Page 347: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

100 }

public int getXpos ( ) {return this . xpos ;

}

public void setXpos ( int xpos ) {this . xpos = xpos ;

}

110 public int getYpos ( ) {return this . ypos ;

}

public void setYpos ( int ypos ) {this . ypos = ypos ;

}

public List<DiagEdge> getDiagEdgesSource ( ) {return this . d iagEdgesSource ;

120 }

public void setDiagEdgesSource ( Lis t<DiagEdge> diagEdgesSource ) {this . d iagEdgesSource = diagEdgesSource ;

}

public List<DiagEdge> getDiagEdgesTarget ( ) {return this . diagEdgesTarget ;

}

130 public void setDiagEdgesTarget ( L is t<DiagEdge> diagEdgesTarget ) {this . diagEdgesTarget = diagEdgesTarget ;

}

public List<Mclass> getMclas se s ( ) {return this . mc las se s ;

}

public void s e tMc la s s e s ( L i s t<Mclass> mclasse s ) {this . mc las se s = mclas se s ;

140 }

public List<Mpackage> getMpackages ( ) {return this . mpackages ;

}

public void setMpackages ( Li s t<Mpackage> mpackages ) {this . mpackages = mpackages ;

}

150 }

D.5.14 Classe DiagEdge.java

329

Page 348: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

import java . u t i l . L i s t ;

@Entity

@Table (name=” diag edge ” )

10 public class DiagEdge implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

@Column(name=”EDGE ID” )

private int edgeId ;

@Column(name=”HREF” )

private St r ing h r e f ;

20@Column(name=”SOURCE” )

private St r ing source ;

@Column(name=”TARGET” )

private St r ing t a r g e t ;

@Column(name=”TYPE” )

private int type ;

30 @ManyToOne

@JoinColumn (name=”SOURCE ID” )

private DiagChi ldren d iagChi ldrenSource ;

@ManyToOne

@JoinColumn (name=”TARGET ID” )

private DiagChi ldren diagChi ldrenTarget ;

@OneToMany(mappedBy=”diagEdge” )

private List<Mfield> m f i e l d s ;

40public DiagEdge ( ) {}

public int getEdgeId ( ) {return this . edgeId ;

}

public void setEdgeId ( int edgeId ) {this . edgeId = edgeId ;

50 }

public St r ing getHre f ( ) {return this . h r e f ;

}

public void s e tHre f ( S t r ing h r e f ) {

330

Page 349: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

this . h r e f = h r e f ;

}

60 public St r ing getSource ( ) {return this . source ;

}

public void s e tSource ( S t r ing source ) {this . source = source ;

}

public St r ing getTarget ( ) {return this . t a r g e t ;

70 }

public void se tTarget ( S t r ing t a r g e t ) {this . t a r g e t = t a r g e t ;

}

public int getType ( ) {return this . type ;

}

80 public void setType ( int type ) {this . type = type ;

}

public DiagChi ldren getDiagChi ldrenSource ( ) {return this . d iagChi ldrenSource ;

}

public void setDiagChi ldrenSource ( DiagChi ldren d iagChi ldrenSource ) {this . d iagChi ldrenSource = diagChi ldrenSource ;

90 }

public DiagChi ldren getDiagChi ldrenTarget ( ) {return this . d iagChi ldrenTarget ;

}

public void setDiagChi ldrenTarget ( DiagChi ldren diagChi ldrenTarget ) {this . d iagChi ldrenTarget = diagChi ldrenTarget ;

}

100 public List<Mfield> ge tMf i e l d s ( ) {return this . m f i e l d s ;

}

public void s e t M f i e l d s ( L is t<Mfield> m f i e l d s ) {this . m f i e l d s = mf i e l d s ;

}

}

331

Page 350: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.5.15 Classe Document.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

import java . u t i l . Date ;

import java . u t i l . L i s t ;

10 @Entity

@Table (name=”document” )

public class Document implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

@Column(name=”DOCUMENT ID” )

private int documentId ;

20@Column(name=”FILENAME” )

private St r ing f i l ename ;

@Temporal ( TemporalType .TIMESTAMP)

@Column(name=”PDF CREATION DATE” )

private Date pdfCreationDate ;

@Temporal ( TemporalType .TIMESTAMP)

@Column(name=”MOD DATE” )

30 private Date modDate ;

@Column(name=”STATUS” )

private St r ing s t a t u s ;

@ManyToOne

@JoinColumn (name=”PROJECT ID” )

private Agreement p r o j e c t ;

@OneToMany(mappedBy=”document” )

40 private List<DocumentHistory> documentHistor ies ;

public Document ( ) {}

public int getDocumentId ( ) {return this . documentId ;

}

public void setDocumentId ( int documentId ) {50 this . documentId = documentId ;

}

public St r ing getFi lename ( ) {

332

Page 351: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return this . f i l ename ;

}

public void setFi lename ( St r ing f i l ename ) {this . f i l ename = f i l ename ;

60 }

public Date getPdfCreat ionDate ( ) {return this . pdfCreat ionDate ;

}

public void setPdfCreat ionDate ( Date pdfCreat ionDate ) {this . pdfCreationDate = pdfCreat ionDate ;

}

70 public St r ing ge tStatus ( ) {return this . s t a t u s ;

}

public void s e t S t a t u s ( S t r ing s t a t u s ) {this . s t a t u s = s t a t u s ;

}

public Agreement ge tPro j e c t ( ) {return this . p r o j e c t ;

80 }

public void s e t P r o j e c t ( Agreement p r o j e c t ) {this . p r o j e c t = p r o j e c t ;

}

public List<DocumentHistory> getDocumentHistor ies ( ) {return this . documentHistor ies ;

}

90 public void setDocumentHistor ies ( L i s t<DocumentHistory> documentHistor ies ) {this . documentHistor ies = documentHistor ies ;

}

public void setModDate ( Date modDate ) {this . modDate = modDate ;

}

public Date getModDate ( ) {return modDate ;

100 }

}

D.5.16 Classe DocumentHistory.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

333

Page 352: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import javax . p e r s i s t e n c e . ∗ ;

import java . u t i l . Date ;

@Entity

10 @Table (name=” document history ” )

public class DocumentHistory implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

@Column(name=”DOCUMENT HISTORY ID” )

private int documentHistoryId ;

@Column(name=”ACTION” )

20 private St r ing ac t i on ;

@Column(name=”COMMENT” )

private St r ing comment ;

@Temporal ( TemporalType .TIMESTAMP)

@Column(name=”MODTIME” )

private Date modtime ;

@Column(name=”NEW STATE” )

30 private St r ing newState ;

@ManyToOne

@JoinColumn (name=”USER ID” )

private User user ;

@Column(name=”ROLE” )

private St r ing r o l e ;

@ManyToOne

40 @JoinColumn (name=”DOCUMENT ID” )

private Document document ;

public DocumentHistory ( ) {}

public int getDocumentHistoryId ( ) {return this . documentHistoryId ;

}

50 public void setDocumentHistoryId ( int documentHistoryId ) {this . documentHistoryId = documentHistoryId ;

}

public St r ing getAct ion ( ) {return this . a c t i on ;

}

public void se tAct ion ( St r ing ac t i on ) {this . a c t i on = act i on ;

334

Page 353: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

60 }

public St r ing getComment ( ) {return this . comment ;

}

public void setComment ( St r ing comment ) {this . comment = comment ;

}

70 public Date getModtime ( ) {return this . modtime ;

}

public void setModtime ( Date modtime ) {this . modtime = modtime ;

}

public St r ing getNewState ( ) {return this . newState ;

80 }

public void setNewState ( S t r ing newState ) {this . newState = newState ;

}

public User getUser ( ) {return this . u se r ;

}

90 public void se tUser ( User user ) {this . u se r = user ;

}

public Document getDocument ( ) {return this . document ;

}

public void setDocument ( Document document ) {this . document = document ;

100 }

public void s e tRo le ( S t r ing r o l e ) {this . r o l e = r o l e ;

}

public St r ing getRole ( ) {return r o l e ;

}

110 }

D.5.17 Classe Entitle.java

335

Page 354: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

import java . u t i l . L i s t ;

public class E n t i t l e implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

10@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

@Column(name=”ENTITLE ID” )

private int e n t i t l e I d ;

@Column(name=”NAME” )

private St r ing name ;

@ManyToMany(mappedBy=” e n t i t l e s ” )

20 private List<Role> r o l e s ;

public E n t i t l e ( ) {}

public int g e t E n t i t l e I d ( ) {return this . e n t i t l e I d ;

}

public void s e t E n t i t l e I d ( int e n t i t l e I d ) {30 this . e n t i t l e I d = e n t i t l e I d ;

}

public St r ing getName ( ) {return this . name ;

}

public void setName ( St r ing name) {this . name = name ;

}40

public List<Role> getRo le s ( ) {return this . r o l e s ;

}

public void s e tRo l e s ( L i s t<Role> r o l e s ) {this . r o l e s = r o l e s ;

}

}

D.5.18 Classe Evidence.java

package i t . uniroma2 . norge . model . jpa ;

336

Page 355: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import i t . uniroma2 . norge . common . AnswerStatus ;

import java . i o . S e r i a l i z a b l e ;

import java . u t i l . Date ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . CascadeType ;

10 import javax . p e r s i s t e n c e . Column ;

import javax . p e r s i s t e n c e . Entity ;

import javax . p e r s i s t e n c e . GeneratedValue ;

import javax . p e r s i s t e n c e . GenerationType ;

import javax . p e r s i s t e n c e . Id ;

import javax . p e r s i s t e n c e . JoinColumn ;

import javax . p e r s i s t e n c e . ManyToOne ;

import javax . p e r s i s t e n c e . OneToMany ;

import javax . p e r s i s t e n c e . Table ;

import javax . p e r s i s t e n c e . Temporal ;

20 import javax . p e r s i s t e n c e . TemporalType ;

import javax . p e r s i s t e n c e . Trans ient ;

@Entity

@Table (name = ” answset answ ” )

public class Evidence implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

30 @Column(name = ”ANSWSET ANSW ID” )

private int answsetAnswId ;

@Temporal ( TemporalType .TIMESTAMP)

@Column(name = ”APPROV LASTMOD” )

private Date approvLastmod ;

@Temporal ( TemporalType .TIMESTAMP)

@Column(name = ”DELIV APPROV LASTMOD” )

private Date approvDelivLastmod ;

40

@Column(name = ”APPROVATION STATUS” )

private St r ing approvat ionStatus ;

@Column(name = ”DELIV APPROVATION STATUS” )

private St r ing approvat ionDe l ivStatus ;

@Transient

private St r ing f i n a l S t a t u s ;

50@Temporal ( TemporalType .TIMESTAMP)

@Column(name = ”FILL LASTMOD” )

private Date f i l l L a s t mod ;

@Column(name = ”RESPONSE” )

private St r ing response ;

337

Page 356: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@ManyToOne( cascade=CascadeType .REFRESH)

@JoinColumn (name = ”ANSWER SET ID” )

60 private AnswerSet answerSet ;

@ManyToOne( cascade=CascadeType .REFRESH)

@JoinColumn (name = ”ANSWER ID” )

private Alternat iveAnswer a l t e rnat iveAnswer ;

@ManyToOne( cascade=CascadeType .REFRESH)

@JoinColumn (name = ”FILL USER ID” )

private User f i l l U s e r ;

70 @ManyToOne( cascade=CascadeType .REFRESH)

@JoinColumn (name = ”APPROV USER ID” )

private User approvUser ;

@ManyToOne( cascade=CascadeType .REFRESH)

@JoinColumn (name = ”DELIV APPROV USER ID” )

private User approvDel ivUser ;

@OneToMany(mappedBy = ”answsetAnsw” , cascade=CascadeType .REFRESH)

private List<Del iverab leEvidence> d e l i v e r a b l e E v i d e n c e s ;

80@OneToMany(mappedBy = ”answsetAnsw” , cascade=CascadeType .REFRESH)

private List<Del iverab leContentHis tory> answsetAnswDel ivHistor ies ;

@ManyToOne( cascade=CascadeType .REFRESH)

@JoinColumn (name = ”FATHER ANSWSETANSW ID” )

private Evidence fatherAnswsetAnsw ;

@OneToMany(mappedBy = ” fatherAnswsetAnsw” , cascade=CascadeType .REFRESH)

private List<Evidence> sonAnswsetAnsws ;

90public Evidence ( ) {}

public int getAnswsetAnswId ( ) {return this . answsetAnswId ;

}

public void setAnswsetAnswId ( int answsetAnswId ) {this . answsetAnswId = answsetAnswId ;

100 }

public Date getApprovLastmod ( ) {return this . approvLastmod ;

}

public void setApprovLastmod ( Date approvLastmod ) {this . approvLastmod = approvLastmod ;

}

110public St r ing getApprovat ionStatus ( ) {

return this . approvat ionStatus ;

}

338

Page 357: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void setApprovat ionStatus ( S t r ing approvat ionStatus ) {this . approvat ionStatus = approvat ionStatus ;

}

public Date getFi l lLastmod ( ) {120 return this . f i l l La s t mod ;

}

public void s e tF i l lLas tmod ( Date f i l l L a s t mod ) {this . f i l l L a s t mod = f i l l La s tm od ;

}

public St r ing getResponse ( ) {return this . r e sponse ;

}130

public void setResponse ( S t r ing response ) {this . r e sponse = response ;

}

public AnswerSet getAnswerSet ( ) {return this . answerSet ;

}

public void setAnswerSet ( AnswerSet answerSet ) {140 this . answerSet = answerSet ;

}

public Alternat iveAnswer getAlternat iveAnswer ( ) {return this . a l t e rnat iveAnswer ;

}

public void se tAlternat iveAnswer ( Alternat iveAnswer a l t e rnat iveAnswer ) {this . a l t e rnat iveAnswer = al te rnat iveAnswer ;

}150

public User g e t F i l l U s e r ( ) {return this . f i l l U s e r ;

}

public void s e t F i l l U s e r ( User f i l l U s e r ) {this . f i l l U s e r = f i l l U s e r ;

}

public User getApprovUser ( ) {160 return this . approvUser ;

}

public void setApprovUser ( User approvUser ) {this . approvUser = approvUser ;

}

public List<Del iverab leEvidence> ge tDe l i v e rab l eEv idence s ( ) {return this . d e l i v e r a b l e E v i d e n c e s ;

}

339

Page 358: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

170public void s e t D e l i v e r a b l e E v i d e n c e s (

Li s t<Del iverab leEvidence> d e l i v e r a b l e E v i d e n c e s ) {this . d e l i v e r a b l e E v i d e n c e s = d e l i v e r a b l e E v i d e n c e s ;

}

public void setAnswsetAnswDel ivHistor ies (

L i s t<Del iverab leContentHis tory> answsetAnswDel ivHistor ies ) {this . answsetAnswDel ivHistor ies = answsetAnswDel ivHistor ies ;

}180

public List<Del iverab leContentHis tory> getAnswsetAnswDel ivHistor ies ( ) {return answsetAnswDel ivHistor ies ;

}

public Date getApprovDelivLastmod ( ) {return approvDelivLastmod ;

}

public void setApprovDelivLastmod ( Date approvDelivLastmod ) {190 this . approvDelivLastmod = approvDelivLastmod ;

}

public St r ing getApprovat ionDel ivStatus ( ) {return approvat ionDe l ivStatus ;

}

public void se tApprovat ionDe l ivStatus ( S t r ing approvat ionDe l ivStatus ) {this . approvat ionDe l ivStatus = approvat ionDe l ivStatus ;

}200

public User getApprovDelivUser ( ) {return approvDel ivUser ;

}

public void setApprovDel ivUser ( User approvDel ivUser ) {this . approvDel ivUser = approvDel ivUser ;

}

public Evidence getFatherAnswsetAnsws ( ) {210 return this . fatherAnswsetAnsw ;

}

public void setFatherAnswsetAnsws ( Evidence f a t h e r A l t e r n a t i v e ) {this . fatherAnswsetAnsw = f a t h e r A l t e r n a t i v e ;

}

public List<Evidence> getSonAnswsetAnsws ( ) {return this . sonAnswsetAnsws ;

}220

public void setSonAnswsetAnsws ( Lis t<Evidence> sonAnswsetAnsws ) {this . sonAnswsetAnsws = sonAnswsetAnsws ;

}

public void s e t F i n a l S t a t u s ( S t r ing f i n a l S t a t u s ) {

340

Page 359: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

this . f i n a l S t a t u s = f i n a l S t a t u s ;

}

public St r ing ge tF ina lS ta tu s ( ) {230 return AnswerStatus . min ( getApprovat ionStatus ( ) , getApprovat ionDel ivStatus ( ) ) ;

}

@Override

public int hashCode ( ) {f ina l int prime = 31 ;

int r e s u l t = 1 ;

r e s u l t = prime ∗ r e s u l t + answsetAnswId ;

return r e s u l t ;

}240

@Override

public boolean equa l s ( Object obj ) {i f ( this == obj )

return true ;

i f ( obj == null )

return fa l se ;

i f ( ge tC la s s ( ) != obj . g e tC la s s ( ) )

return fa l se ;

Evidence other = ( Evidence ) obj ;

250 i f ( answsetAnswId != other . answsetAnswId )

return fa l se ;

return true ;

}

}

D.5.19 Classe Mclass.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

import java . u t i l . L i s t ;

@Entity

@Table (name = ” mclass ” )

10 public class Mclass implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

@Column(name = ”CLASS ID” )

private int c l a s s I d ;

@Lob( )

@Column(name = ”ANNOTATION” )

20 private St r ing annotat ion ;

341

Page 360: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Column(name = ”CANONICAL NAME” )

private St r ing canonicalName ;

@Column(name = ”NAME” )

private St r ing name ;

@Column(name = ”SUPER TYPE” )

private St r ing superType ;

30@Column(name = ”XSITYPE” )

private St r ing x s i type ;

@ManyToOne( cascade = CascadeType . PERSIST)

@JoinColumn (name = ”CHILDREN ID” )

private DiagChi ldren d iagChi ldren ;

@ManyToOne( cascade = CascadeType . PERSIST)

@JoinColumn (name = ”SUPER TYPE ID” )

40 private Mclass parentClass ;

@OneToMany(mappedBy = ” parentClass ” , cascade = CascadeType . PERSIST)

private List<Mclass> c h i l d C l a s s e s ;

@ManyToOne( cascade = CascadeType . PERSIST)

@JoinColumn (name = ”PACKAGE ID” )

private Mpackage mpackage ;

@OneToMany(mappedBy = ” ownerClass ” , cascade = CascadeType . PERSIST)

50 private List<Mfield> ownedClasses ;

@OneToMany(mappedBy = ” typeClass ” , cascade = CascadeType . PERSIST)

private List<Mfield> f i e l d s ;

@OneToMany(mappedBy = ” mclass ” , cascade = CascadeType . PERSIST)

private List<Ml i t e ra l> m l i t e r a l s ;

@OneToMany(mappedBy = ” mclass ” )

private List<Question> que s t i on s ;

60public Mclass ( ) {}

public int ge tC la s s Id ( ) {return this . c l a s s I d ;

}

public void s e t C l a s s I d ( int c l a s s I d ) {this . c l a s s I d = c l a s s I d ;

70 }

public St r ing getAnnotation ( ) {return this . annotat ion ;

}

public void setAnnotat ion ( S t r ing annotat ion ) {this . annotat ion = annotat ion ;

342

Page 361: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

80 public St r ing getCanonicalName ( ) {return this . canonicalName ;

}

public void setCanonicalName ( St r ing canonicalName ) {this . canonicalName = canonicalName ;

}

public St r ing getName ( ) {return this . name ;

90 }

public void setName ( St r ing name) {this . name = name ;

}

public St r ing getSuperType ( ) {return this . superType ;

}

100 public void setSuperType ( St r ing superType ) {this . superType = superType ;

}

public St r ing getXs i type ( ) {return this . x s i t ype ;

}

public void s e tXs i type ( S t r ing x s i type ) {this . x s i t ype = xs i type ;

110 }

public DiagChi ldren getDiagChi ldren ( ) {return this . d iagChi ldren ;

}

public void se tDiagChi ldren ( DiagChi ldren d iagChi ldren ) {this . d iagChi ldren = diagChi ldren ;

}

120 public Mclass getParentClass ( ) {return this . parentClass ;

}

public void s e tParentClas s ( Mclass parentClass ) {this . parentClass = parentClass ;

}

public List<Mclass> ge tCh i ldC la s s e s ( ) {return this . c h i l d C l a s s e s ;

130 }

public void s e t C h i l d C l a s s e s ( L i s t<Mclass> c h i l d C l a s s e s ) {this . c h i l d C l a s s e s = c h i l d C l a s s e s ;

343

Page 362: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

public Mpackage getMpackage ( ) {return this . mpackage ;

}

140 public void setMpackage ( Mpackage mpackage ) {this . mpackage = mpackage ;

}

public List<Mfield> getOwnedClasses ( ) {return this . ownedClasses ;

}

public void setOwnedClasses ( L i s t<Mfield> ownedClasses ) {this . ownedClasses = ownedClasses ;

150 }

public List<Mfield> g e t F i e l d s ( ) {return this . f i e l d s ;

}

public void s e t F i e l d s ( L is t<Mfield> f i e l d s ) {this . f i e l d s = f i e l d s ;

}

160 public List<Ml i t e ra l> g e t M l i t e r a l s ( ) {return this . m l i t e r a l s ;

}

public void s e t M l i t e r a l s ( L i s t<Ml i t e ra l> m l i t e r a l s ) {this . m l i t e r a l s = m l i t e r a l s ;

}

public List<Question> getQuest ions ( ) {return this . que s t i on s ;

170 }

public void s e tQues t i ons ( Li s t<Question> que s t i on s ) {this . que s t i on s = que s t i on s ;

}

@Override

public int hashCode ( ) {f ina l int prime = 31 ;

int r e s u l t = 1 ;

180 r e s u l t = prime ∗ r e s u l t

+ ( ( canonicalName == null ) ? 0 : canonicalName . hashCode ( ) ) ;

r e s u l t = prime ∗ r e s u l t + c l a s s I d ;

r e s u l t = prime ∗ r e s u l t + ( ( name == null ) ? 0 : name . hashCode ( ) ) ;

return r e s u l t ;

}

@Override

public boolean equa l s ( Object obj ) {i f ( this == obj ) {

344

Page 363: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

190 return true ;

}i f ( obj == null ) {

return fa l se ;

}i f ( ! ( obj instanceof Mclass ) ) {

return fa l se ;

}Mclass other = ( Mclass ) obj ;

i f ( canonicalName == null ) {200 i f ( other . canonicalName != null ) {

return fa l se ;

}} else i f ( ! canonicalName . equa l s ( other . canonicalName ) ) {

return fa l se ;

}i f ( c l a s s I d != other . c l a s s I d ) {

return fa l se ;

}i f (name == null ) {

210 i f ( other . name != null ) {return fa l se ;

}} else i f ( ! name . equa l s ( other . name) ) {

return fa l se ;

}return true ;

}

public St r ing toS t r i ng ( ) {220 return name ;

}}

D.5.20 Classe Mfield.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import java . math . B ig In tege r ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . CascadeType ;

import javax . p e r s i s t e n c e . Column ;

import javax . p e r s i s t e n c e . Entity ;

10 import javax . p e r s i s t e n c e . GeneratedValue ;

import javax . p e r s i s t e n c e . GenerationType ;

import javax . p e r s i s t e n c e . Id ;

import javax . p e r s i s t e n c e . JoinColumn ;

import javax . p e r s i s t e n c e . ManyToOne ;

import javax . p e r s i s t e n c e . OneToMany ;

import javax . p e r s i s t e n c e . Table ;

@Entity

345

Page 364: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Table (name = ” mf i e ld ” )

20 public class Mfie ld implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

@Column(name = ”FIELD ID” )

private int f i e l d I d ;

@Column(name = ”CANONICAL NAME” )

private St r ing canonicalName ;

30@Column(name = ”LOWERBOUND” )

private Big Intege r lowerBound ;

@Column(name = ”NAME” )

private St r ing name ;

@Column(name = ”OPPOSITE” )

private St r ing oppos i t e ;

40 @Column(name = ”TYPE” )

private St r ing type ;

@Column(name = ”UPPER BOUND” )

private Big Intege r upperBound ;

@ManyToOne( cascade = CascadeType . PERSIST)

@JoinColumn (name = ”EDGE ID” )

private DiagEdge diagEdge ;

50 @ManyToOne( cascade = CascadeType . PERSIST)

@JoinColumn (name = ”OPPOSITE FIELD ID” )

private Mfie ld o p p o s i t e F i e l d ;

@OneToMany(mappedBy = ” o p p o s i t e F i e l d ” , cascade = CascadeType . PERSIST)

private List<Mfield> o p p o s i t e F i e l d s ;

@ManyToOne( cascade = CascadeType . PERSIST)

@JoinColumn (name = ”OWNER CLASS ID” )

private Mclass ownerClass ;

60@ManyToOne( cascade = CascadeType . PERSIST)

@JoinColumn (name = ”TYPE CLASS ID” )

private Mclass typeClass ;

@OneToMany(mappedBy = ” mf ie ldSource ” )

private List<Relat ion> r e l a t i o n s S o u r c e ;

@OneToMany(mappedBy = ” mf ie ldTarget ” )

private List<Relat ion> r e l a t i o n s T a r g e t ;

70public Mfie ld ( ) {}

public int g e t F i e l d I d ( ) {

346

Page 365: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return this . f i e l d I d ;

}

public void s e t F i e l d I d ( int f i e l d I d ) {this . f i e l d I d = f i e l d I d ;

80 }

public St r ing getCanonicalName ( ) {return this . canonicalName ;

}

public void setCanonicalName ( St r ing canonicalName ) {this . canonicalName = canonicalName ;

}

90 public Big Intege r getLowerBound ( ) {return this . lowerBound ;

}

public void setLowerBound ( Big Intege r lowerBound ) {this . lowerBound = lowerBound ;

}

public St r ing getName ( ) {return this . name ;

100 }

public void setName ( St r ing name) {this . name = name ;

}

public St r ing getOppos i te ( ) {return this . oppos i t e ;

}

110 public void se tOppos i te ( S t r ing oppos i t e ) {this . oppos i t e = oppos i t e ;

}

public St r ing getType ( ) {return this . type ;

}

public void setType ( S t r ing type ) {this . type = type ;

120 }

public Big Intege r getUpperBound ( ) {return this . upperBound ;

}

public void setUpperBound ( Big Intege r upperBound ) {this . upperBound = upperBound ;

}

130 public DiagEdge getDiagEdge ( ) {

347

Page 366: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return this . diagEdge ;

}

public void setDiagEdge ( DiagEdge diagEdge ) {this . diagEdge = diagEdge ;

}

public Mfie ld getOppos i t eF ie ld ( ) {return this . o p p o s i t e F i e l d ;

140 }

public void s e tOppos i t eF i e ld ( Mf ie ld o p p o s i t e F i e l d ) {this . o p p o s i t e F i e l d = o p p o s i t e F i e l d ;

}

public List<Mfield> ge tOppos i t eF i e ld s ( ) {return this . o p p o s i t e F i e l d s ;

}

150 public void s e tOppos i t eF i e l d s ( L is t<Mfield> o p p o s i t e F i e l d s ) {this . o p p o s i t e F i e l d s = o p p o s i t e F i e l d s ;

}

public Mclass getOwnerClass ( ) {return this . ownerClass ;

}

public void setOwnerClass ( Mclass ownerClass ) {this . ownerClass = ownerClass ;

160 }

public Mclass getTypeClass ( ) {return this . typeClass ;

}

public void setTypeClass ( Mclass typeClass ) {this . typeClass = typeClass ;

}

170 public void s e tRe l a t i on sSour c e ( Lis t<Relat ion> r e l a t i o n s S o u r c e ) {this . r e l a t i o n s S o u r c e = r e l a t i o n s S o u r c e ;

}

public List<Relat ion> ge tRe la t i onsSource ( ) {return r e l a t i o n s S o u r c e ;

}

public void s e tRe l a t i on sTarge t ( L is t<Relat ion> r e l a t i o n s T a r g e t ) {this . r e l a t i o n s T a r g e t = r e l a t i o n s T a r g e t ;

180 }

public List<Relat ion> getRe la t i onsTarge t ( ) {return r e l a t i o n s T a r g e t ;

}

}

348

Page 367: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.5.21 Classe Mliteral.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

@Entity

@Table (name=” m l i t e r a l ” )

public class M l i t e r a l implements S e r i a l i z a b l e {10 private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

@Column(name=”LITERAL ID” )

private int l i t e r a l I d ;

@Column(name=”VALUE” )

private St r ing value ;

20 @ManyToOne

@JoinColumn (name=”CLASS ID” )

private Mclass mclass ;

public M l i t e r a l ( ) {}

public int g e t L i t e r a l I d ( ) {return this . l i t e r a l I d ;

}30

public void s e t L i t e r a l I d ( int l i t e r a l I d ) {this . l i t e r a l I d = l i t e r a l I d ;

}

public St r ing getValue ( ) {return this . va lue ;

}

public void setValue ( S t r ing value ) {40 this . va lue = value ;

}

public Mclass getMclass ( ) {return this . mclass ;

}

public void se tMc las s ( Mclass mclass ) {this . mclass = mclass ;

}50}

349

Page 368: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.5.22 Classe Model.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

import java . u t i l . L i s t ;

@Entity

10 @Table (name=”model” )

public class Model implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

@Column(name=”MODEL ID” )

private int modelId ;

@Column(name=”DESCRIPTION” )

20 private St r ing d e s c r i p t i o n ;

@Lob( )

@Column(name=”ECORE XML” )

private St r ing ecoreXml ;

@Lob( )

@Column(name=”ECOREDIAG XML” )

private St r ing ecorediagXml ;

30 @OneToMany(mappedBy=”model” , cascade=CascadeType . PERSIST)

private List<Mpackage> mpackages ;

@OneToMany(mappedBy=”model” )

private List<Quest ionnaire> q u e s t i o n n a i r e s ;

public Model ( ) {}

public int getModelId ( ) {40 return this . modelId ;

}

public void setModelId ( int modelId ) {this . modelId = modelId ;

}

public St r ing ge tDe s c r i p t i on ( ) {return this . d e s c r i p t i o n ;

}50

public void s e t D e s c r i p t i o n ( S t r ing d e s c r i p t i o n ) {this . d e s c r i p t i o n = d e s c r i p t i o n ;

}

350

Page 369: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public St r ing getEcoreXml ( ) {return this . ecoreXml ;

}

public void setEcoreXml ( S t r ing ecoreXml ) {60 this . ecoreXml = ecoreXml ;

}

public St r ing getEcorediagXml ( ) {return this . ecorediagXml ;

}

public void setEcorediagXml ( St r ing ecorediagXml ) {this . ecorediagXml = ecorediagXml ;

}70

public List<Mpackage> getMpackages ( ) {return this . mpackages ;

}

public void setMpackages ( Li s t<Mpackage> mpackages ) {this . mpackages = mpackages ;

}

public List<Quest ionnaire> ge tQues t i onna i r e s ( ) {80 return this . q u e s t i o n n a i r e s ;

}

public void s e t Q u e s t i o n n a i r e s ( L i s t<Quest ionnaire> q u e s t i o n n a i r e s ) {this . q u e s t i o n n a i r e s = q u e s t i o n n a i r e s ;

}

@Override

public int hashCode ( ) {f ina l int prime = 31 ;

90 int r e s u l t = 1 ;

r e s u l t = prime ∗ r e s u l t

+ ( ( d e s c r i p t i o n == null ) ? 0 : d e s c r i p t i o n . hashCode ( ) ) ;

r e s u l t = prime ∗ r e s u l t + modelId ;

return r e s u l t ;

}

@Override

public boolean equa l s ( Object obj ) {i f ( this == obj ) {

100 return true ;

}i f ( obj == null ) {

return fa l se ;

}i f ( ! ( obj instanceof Model ) ) {

return fa l se ;

}Model other = ( Model ) obj ;

i f ( d e s c r i p t i o n == null ) {110 i f ( other . d e s c r i p t i o n != null ) {

351

Page 370: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return fa l se ;

}} else i f ( ! d e s c r i p t i o n . equa l s ( other . d e s c r i p t i o n ) ) {

return fa l se ;

}i f ( modelId != other . modelId ) {

return fa l se ;

}return true ;

120 }

public St r ing toS t r i ng ( ) {return d e s c r i p t i o n ;

}

}

D.5.23 Classe Mpackage.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

import java . u t i l . L i s t ;

@Entity

10 @Table (name=”mpackage” )

public class Mpackage implements S e r i a l i z a b l e , Comparable<Mpackage> {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

@Column(name=”PACKAGE ID” )

private int packageId ;

@Column(name=”CANONICAL NAME” )

20 private St r ing canonicalName ;

@Column(name=”NAME” )

private St r ing name ;

@Lob( )

@Column(name=”PATH” )

private St r ing path ;

@OneToMany(mappedBy=”mpackage” , cascade=CascadeType . PERSIST)

30 private List<Mclass> mclasse s ;

@ManyToOne( cascade = CascadeType . PERSIST)

@JoinColumn (name=”CHILDREN ID” )

private DiagChi ldren d iagChi ldren ;

352

Page 371: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@ManyToOne( cascade = CascadeType . PERSIST)

@JoinColumn (name=”MODEL ID” )

private Model model ;

40 @ManyToOne( cascade = CascadeType . PERSIST)

@JoinColumn (name=”FATHER ID” )

private Mpackage mpackage ;

@OneToMany(mappedBy=”mpackage” , cascade=CascadeType . PERSIST)

private List<Mpackage> mpackages ;

@OneToMany(mappedBy=”mpackage” , cascade=CascadeType .REFRESH)

private List<Question> que s t i on s ;

50 public Mpackage ( ) {}

public int getPackageId ( ) {return this . packageId ;

}

public void setPackageId ( int packageId ) {this . packageId = packageId ;

}60

public St r ing getCanonicalName ( ) {return this . canonicalName ;

}

public void setCanonicalName ( St r ing canonicalName ) {this . canonicalName = canonicalName ;

}

public St r ing getName ( ) {70 return this . name ;

}

public void setName ( St r ing name) {this . name = name ;

}

public St r ing getPath ( ) {return this . path ;

}80

public void setPath ( St r ing path ) {this . path = path ;

}

public List<Mclass> getMclas se s ( ) {return this . mc las se s ;

}

public void s e tMc la s s e s ( L i s t<Mclass> mclasse s ) {90 this . mc las se s = mclas se s ;

}

353

Page 372: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public DiagChi ldren getDiagChi ldren ( ) {return this . d iagChi ldren ;

}

public void se tDiagChi ldren ( DiagChi ldren d iagChi ldren ) {this . d iagChi ldren = diagChi ldren ;

}100

public Model getModel ( ) {return this . model ;

}

public void setModel ( Model model ) {this . model = model ;

}

public Mpackage getMpackage ( ) {110 return this . mpackage ;

}

public void setMpackage ( Mpackage mpackage ) {this . mpackage = mpackage ;

}

public List<Mpackage> getMpackages ( ) {return this . mpackages ;

}120

public void setMpackages ( Li s t<Mpackage> mpackages ) {this . mpackages = mpackages ;

}

public List<Question> getQuest ions ( ) {return this . que s t i on s ;

}

public void s e tQues t i ons ( Li s t<Question> que s t i on s ) {130 this . que s t i on s = que s t i on s ;

}

@Override

public int hashCode ( ) {f ina l int prime = 31 ;

int r e s u l t = 1 ;

r e s u l t = prime ∗ r e s u l t

+ ( ( canonicalName == null ) ? 0 : canonicalName . hashCode ( ) ) ;

r e s u l t = prime ∗ r e s u l t + ( ( name == null ) ? 0 : name . hashCode ( ) ) ;

140 r e s u l t = prime ∗ r e s u l t + packageId ;

return r e s u l t ;

}

@Override

public boolean equa l s ( Object obj ) {i f ( this == obj ) {

return true ;

354

Page 373: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}i f ( obj == null ) {

150 return fa l se ;

}i f ( ! ( obj instanceof Mpackage ) ) {

return fa l se ;

}Mpackage other = ( Mpackage ) obj ;

i f ( canonicalName == null ) {i f ( other . canonicalName != null ) {

return fa l se ;

}160 } else i f ( ! canonicalName . equa l s ( other . canonicalName ) ) {

return fa l se ;

}i f (name == null ) {

i f ( other . name != null ) {return fa l se ;

}} else i f ( ! name . equa l s ( other . name) ) {

return fa l se ;

}170 i f ( packageId != other . packageId ) {

return fa l se ;

}return true ;

}

public St r ing toS t r i ng ( ) {return canonicalName ;

180 }

@Override

public int compareTo ( Mpackage o ) {i f ( getPackageId ( ) > o . getPackageId ( ) )

return 1 ;

i f ( getPackageId ( ) < o . getPackageId ( ) )

return −1 ;

return 0 ;

}190

}

D.5.24 Classe Organization.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

import java . u t i l . L i s t ;

355

Page 374: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Entity

@Table (name=” o r g a n i z a t i on ” )

10 public class Organizat ion implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

@Column(name=” o r g a n i z a t i o n i d ” )

private int o r g a n i z a t i o n I d ;

private St r ing country ;

20 private St r ing name ;

private St r ing type ;

@OneToMany(mappedBy=” o r g a n i z a t i o n S u p p l i e r ” )

private List<Agreement> p r o j e c t s S ;

@OneToMany(mappedBy=” o r g a n i z a t i o n C e r t i f i e r ” )

private List<Agreement> pro jec t sC ;

30 @OneToMany(mappedBy=” or g a n i z a t i o n ” )

private List<User> use r s ;

public Organizat ion ( ) {}

public int getOrgan i zat ionId ( ) {return this . o r g a n i z a t i o n I d ;

}

40 public void s e tOrgan i za t i on Id ( int o r g a n i z a t i o n I d ) {this . o r g a n i z a t i o n I d = o r g a n i z a t i o n I d ;

}

public St r ing getCountry ( ) {return this . country ;

}

public void setCountry ( S t r ing country ) {this . country = country ;

50 }

public St r ing getName ( ) {return this . name ;

}

public void setName ( St r ing name) {this . name = name ;

}

60 public St r ing getType ( ) {return this . type ;

}

356

Page 375: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void setType ( S t r ing type ) {this . type = type ;

}

public List<Agreement> ge tPro j e c t sS ( ) {return this . p r o j e c t s S ;

70 }

public void s e t P r o j e c t s S ( Lis t<Agreement> p r o j e c t s S ) {this . p r o j e c t s S = p r o j e c t s S ;

}

public List<User> getUsers ( ) {return this . u s e r s ;

}

80 public void s e tUse r s ( L i s t<User> use r s ) {this . u s e r s = use r s ;

}

public List<Agreement> getPro jec t sC ( ) {return pro jec t sC ;

}

public void s e tPro j e c t sC ( List<Agreement> pro jec t sC ) {this . p ro j ec t sC = pro jec t sC ;

90 }

@Override

public St r ing toS t r i ng ( ) {return name+” ( ” + country + ”/” + type + ” ) ” ;

}

@Override

public int hashCode ( ) {f ina l int prime = 31 ;

100 int r e s u l t = 1 ;

r e s u l t = prime ∗ r e s u l t + ( ( name == null ) ? 0 : name . hashCode ( ) ) ;

r e s u l t = prime ∗ r e s u l t + o r g a n i z a t i o n I d ;

return r e s u l t ;

}

@Override

public boolean equa l s ( Object obj ) {i f ( this == obj )

return true ;

110 i f ( obj == null )

return fa l se ;

i f ( ge tC la s s ( ) != obj . g e tC la s s ( ) )

return fa l se ;

Organizat ion other = ( Organizat ion ) obj ;

i f (name == null ) {i f ( other . name != null )

return fa l se ;

} else i f ( ! name . equa l s ( other . name) )

return fa l se ;

357

Page 376: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

120 i f ( o r g a n i z a t i o n I d != other . o r g a n i z a t i o n I d )

return fa l se ;

return true ;

}

}

D.5.25 Classe Question.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . CascadeType ;

import javax . p e r s i s t e n c e . Column ;

import javax . p e r s i s t e n c e . Entity ;

import javax . p e r s i s t e n c e . GeneratedValue ;

10 import javax . p e r s i s t e n c e . GenerationType ;

import javax . p e r s i s t e n c e . Id ;

import javax . p e r s i s t e n c e . JoinColumn ;

import javax . p e r s i s t e n c e . Lob ;

import javax . p e r s i s t e n c e . ManyToOne ;

import javax . p e r s i s t e n c e . OneToMany ;

import javax . p e r s i s t e n c e . Table ;

@Entity

@Table (name = ” ques t i on ” )

20 public class Question implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

@Column(name = ”QUESTION ID” )

private int ques t i on Id ;

@Lob( )

@Column(name = ”QUESTION” )

30 private St r ing ques t i on ;

@Column(name = ”QUESTION CODE” )

private St r ing questionCode ;

@Column(name = ”SINGLE MULTIPLE” )

private St r ing s i n g l e M u l t i p l e ;

@Column(name = ”LOWERBOUND” )

private int lowerbound ;

40@Column(name = ”UPPERBOUND” )

private int upperbound ;

@Column(name = ”OPEN QUESTION” )

private St r ing openQuestion ;

358

Page 377: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@OneToMany(mappedBy = ” ques t i on ” , cascade=CascadeType .REFRESH)

private List<AlternativeAnswer> a l t e rnat iveAnswer s ;

50 @OneToMany(mappedBy = ” ques t i on ” , cascade=CascadeType .REFRESH)

private List<AnswerSet> answerSets ;

@ManyToOne

@JoinColumn (name = ”QUESTIONNAIRE ID” )

private Quest ionna i re q u e s t i o n n a i r e ;

@ManyToOne

@JoinColumn (name = ”CLASS ID” )

private Mclass mclass ;

60

@ManyToOne

@JoinColumn (name = ”PACKAGE ID” )

private Mpackage mpackage ;

@OneToMany(mappedBy = ” ques t i on ” )

private List<RuleMul tep l i c i ty> r u l e M u l t e p l i c i t i e s ;

@Column(name = ”SIL DEPENDENT” )

70 private Boolean s i lDependent ;

@Column(name = ”CONTEXT DEF” )

private Boolean c o n t e x t D e f i n i t i o n ;

@ManyToOne

@JoinColumn (name=”RELATION id” )

private Relat ion r e l a t i o n ;

public Question ( ) {80 }

public int getQuest ionId ( ) {return this . que s t i on Id ;

}

public void s e tQuest ionId ( int ques t i on Id ) {this . que s t i on Id = ques t i on Id ;

}

90 public St r ing getQuest ion ( ) {return this . que s t i on ;

}

public void se tQuest ion ( S t r ing ques t i on ) {this . ques t i on = ques t i on ;

}

public St r ing getQuestionCode ( ) {return this . questionCode ;

100 }

359

Page 378: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void setQuestionCode ( S t r ing questionCode ) {this . questionCode = questionCode ;

}

public St r ing g e t S i n g l e M u l t i p l e ( ) {return this . s i n g l e M u l t i p l e ;

}

110 public void s e t S i n g l e M u l t i p l e ( S t r ing s i n g l e M u l t i p l e ) {this . s i n g l e M u l t i p l e = s i n g l e M u l t i p l e ;

}

public List<AlternativeAnswer> getAlternat iveAnswers ( ) {return this . a l t e rnat iveAnswer s ;

}

public void s e tAl te rnat iveAnswers ( Li s t<AlternativeAnswer> a l t e rnat iveAnswer s ) {this . a l t e rnat iveAnswer s = a l t e rnat iveAnswer s ;

120 }

public List<AnswerSet> getAnswerSets ( ) {return this . answerSets ;

}

public void setAnswerSets ( L i s t<AnswerSet> answerSets ) {this . answerSets = answerSets ;

}

130 public Quest ionna i re ge tQues t i onna i r e ( ) {return this . q u e s t i o n n a i r e ;

}

public void s e tQue s t i onna i r e ( Quest ionna i re q u e s t i o n n a i r e ) {this . q u e s t i o n n a i r e = q u e s t i o n n a i r e ;

}

public Mclass getMclass ( ) {return this . mclass ;

140 }

public void se tMc las s ( Mclass mclass ) {this . mclass = mclass ;

}

public Mpackage getMpackage ( ) {return this . mpackage ;

}

150 public void setMpackage ( Mpackage mpackage ) {this . mpackage = mpackage ;

}

public List<RuleMul tep l i c i ty> g e t R u l e M u l t e p l i c i t i e s ( ) {return this . r u l e M u l t e p l i c i t i e s ;

}

360

Page 379: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void s e t R u l e M u l t e p l i c i t i e s ( L i s t<RuleMul tep l i c i ty> r u l e M u l t e p l i c i t i e s ) {this . r u l e M u l t e p l i c i t i e s = r u l e M u l t e p l i c i t i e s ;

160 }

@Override

public int hashCode ( ) {f ina l int prime = 31 ;

int r e s u l t = 1 ;

r e s u l t = prime ∗ r e s u l t

+ ( ( ques t i on == null ) ? 0 : ques t i on . hashCode ( ) ) ;

r e s u l t = prime ∗ r e s u l t

+ ( ( questionCode == null ) ? 0 : questionCode . hashCode ( ) ) ;

170 r e s u l t = prime ∗ r e s u l t + ques t i on Id ;

return r e s u l t ;

}

@Override

public boolean equa l s ( Object obj ) {i f ( this == obj ) {

return true ;

}i f ( obj == null ) {

180 return fa l se ;

}i f ( ! ( obj instanceof Question ) ) {

return fa l se ;

}Question other = ( Question ) obj ;

i f ( ques t i on == null ) {i f ( other . ques t i on != null ) {

return fa l se ;

}190 } else i f ( ! ques t i on . equa l s ( other . ques t i on ) ) {

return fa l se ;

}i f ( questionCode == null ) {

i f ( other . questionCode != null ) {return fa l se ;

}} else i f ( ! questionCode . equa l s ( other . questionCode ) ) {

return fa l se ;

}200 i f ( que s t i on Id != other . que s t i on Id ) {

return fa l se ;

}return true ;

}

public St r ing toS t r i ng ( ) {return ques t i on ;

}

210 public void setOpenQuestion ( S t r ing openQuestion ) {this . openQuestion = openQuestion ;

}

361

Page 380: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public St r ing getOpenQuestion ( ) {return openQuestion ;

}

public void setLowerbound ( int lowerbound ) {this . lowerbound = lowerbound ;

220 }

public int getLowerbound ( ) {return lowerbound ;

}

public void setUpperbound ( int upperbound ) {this . upperbound = upperbound ;

}

230 public int getUpperbound ( ) {return upperbound ;

}

public void se tS i lDependent ( Boolean s i lDependent ) {this . s i lDependent = s i lDependent ;

}

public Boolean getS i lDependent ( ) {return s i lDependent ;

240 }

public void s e tCont ex tDe f i n i t i on ( Boolean c o n t e x t D e f i n i t i o n ) {i f ( c o n t e x t D e f i n i t i o n == null )

c o n t e x t D e f i n i t i o n = fa l se ;

this . c o n t e x t D e f i n i t i o n = c o n t e x t D e f i n i t i o n ;

}

public Boolean ge tContex tDe f in i t i on ( ) {i f ( c o n t e x t D e f i n i t i o n == null )

250 return fa l se ;

return c o n t e x t D e f i n i t i o n ;

}

public St r ing getSi lDependent2 ( ) {i f ( s i lDependent == null | | s i lDependent == fa l se )

return ”” ;

else

return ”∗” ;

}260

public St r ing ge tContextDe f in i t i on2 ( ) {i f ( c o n t e x t D e f i n i t i o n == null | | c o n t e x t D e f i n i t i o n == fa l se )

return ”” ;

else

return ”∗” ;

}

public void s e t R e l a t i o n ( Re lat ion r e l a t i o n ) {this . r e l a t i o n = r e l a t i o n ;

362

Page 381: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

270 }

public Relat ion ge tRe la t i on ( ) {return r e l a t i o n ;

}}

D.5.26 Classe Questionnaire.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . Column ;

import javax . p e r s i s t e n c e . Entity ;

import javax . p e r s i s t e n c e . GeneratedValue ;

import javax . p e r s i s t e n c e . GenerationType ;

10 import javax . p e r s i s t e n c e . Id ;

import javax . p e r s i s t e n c e . JoinColumn ;

import javax . p e r s i s t e n c e . ManyToOne ;

import javax . p e r s i s t e n c e . OneToMany ;

import javax . p e r s i s t e n c e . OneToOne ;

import javax . p e r s i s t e n c e . Table ;

@Entity

@Table (name = ” q u e s t i o n n a i r e ” )

public class Quest ionna i re implements S e r i a l i z a b l e {20 private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

@Column(name = ”QUESTIONNAIRE ID” )

private int q u e s t i o n n a i r e I d ;

@OneToMany(mappedBy = ” q u e s t i o n n a i r e ” )

private List<Agreement> p r o j e c t s ;

30 @OneToMany(mappedBy = ” q u e s t i o n n a i r e ” )

private List<Question> que s t i on s ;

@ManyToOne

@JoinColumn (name = ”MODEL ID” )

private Model model ;

@OneToOne

@JoinColumn (name = ”SIL QUESTION ID” )

private Question s i l Q u e s t i o n ;

40@Column(name = ”NAME” )

private St r ing name ;

public Quest ionna i re ( ) {}

363

Page 382: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public int ge tQues t i onna i r e Id ( ) {return this . q u e s t i o n n a i r e I d ;

}50

public void s e tQue s t i onna i r e Id ( int q u e s t i o n n a i r e I d ) {this . q u e s t i o n n a i r e I d = q u e s t i o n n a i r e I d ;

}

public List<Agreement> g e t P r o j e c t s ( ) {return this . p r o j e c t s ;

}

public void s e t P r o j e c t s ( L i s t<Agreement> p r o j e c t s ) {60 this . p r o j e c t s = p r o j e c t s ;

}

public List<Question> getQuest ions ( ) {return this . que s t i on s ;

}

public void s e tQues t i ons ( Li s t<Question> que s t i on s ) {this . que s t i on s = que s t i on s ;

}70

public Model getModel ( ) {return this . model ;

}

public void setModel ( Model model ) {this . model = model ;

}

public Question ge tS i lQue s t i on ( ) {80 return this . s i l Q u e s t i o n ;

}

public void s e t S i l Q u e s t i o n ( Question s i l Q u e s t i o n ) {this . s i l Q u e s t i o n = s i l Q u e s t i o n ;

}

@Override

public int hashCode ( ) {f ina l int prime = 31 ;

90 int r e s u l t = 1 ;

r e s u l t = prime ∗ r e s u l t + q u e s t i o n n a i r e I d ;

return r e s u l t ;

}

@Override

public boolean equa l s ( Object obj ) {i f ( this == obj ) {

return true ;

}100 i f ( obj == null ) {

return fa l se ;

364

Page 383: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}i f ( ! ( obj instanceof Quest ionna i re ) ) {

return fa l se ;

}Quest ionna i re other = ( Quest ionna i re ) obj ;

i f ( q u e s t i o n n a i r e I d != other . q u e s t i o n n a i r e I d ) {return fa l se ;

}110 return true ;

}

public St r ing toS t r i ng ( ) {return name ;

}

public void setName ( St r ing name) {this . name = name ;

}120

public St r ing getName ( ) {return name ;

}

}

D.5.27 Classe Relation.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . Column ;

import javax . p e r s i s t e n c e . Entity ;

import javax . p e r s i s t e n c e . GeneratedValue ;

import javax . p e r s i s t e n c e . GenerationType ;

10 import javax . p e r s i s t e n c e . Id ;

import javax . p e r s i s t e n c e . JoinColumn ;

import javax . p e r s i s t e n c e . ManyToOne ;

import javax . p e r s i s t e n c e . OneToMany ;

import javax . p e r s i s t e n c e . Table ;

@Entity

@Table (name=” r e l a t i o n ” )

public class Relat ion implements S e r i a l i z a b l e , Comparable<Relat ion> {20 private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

@Column(name=”RELATION ID” )

private int r e l a t i o n I d ;

@Column(name=”NAME” )

365

Page 384: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private St r ing name ;

30 @OneToMany(mappedBy=” r e l a t i o n ” )

private List<Question> que s t i on s ;

@ManyToOne

@JoinColumn (name=”RELATION CLASS” )

private Mclass mclass ;

@ManyToOne

@JoinColumn (name=”SOURCE FIELD ID” )

private Mfie ld mf i e ldSource ;

40@ManyToOne

@JoinColumn (name=”TARGET FIELD ID” )

private Mfie ld mf ie ldTarget ;

public Relat ion ( ) {}

public int ge tRe la t i on Id ( ) {return this . r e l a t i o n I d ;

50 }

public void s e t R e l a t i o n I d ( int r e l a t i o n I d ) {this . r e l a t i o n I d = r e l a t i o n I d ;

}

public St r ing getName ( ) {return this . name ;

}

60 public void setName ( St r ing name) {this . name = name ;

}

public List<Question> getQuest ions ( ) {return this . que s t i on s ;

}

public void s e tQues t i ons ( Li s t<Question> que s t i on s ) {this . que s t i on s = que s t i on s ;

70 }

public Mclass getMclass ( ) {return this . mclass ;

}

public void se tMc las s ( Mclass mclass ) {this . mclass = mclass ;

}

80 public Mfie ld getMf i e ldSource ( ) {return this . mf i e ldSource ;

}

366

Page 385: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void s e tMf i e ldSource ( Mf ie ld mf i e ldSource ) {this . mf i e ldSource = mf ie ldSource ;

}

public Mfie ld getMf ie ldTarget ( ) {return this . mf ie ldTarget ;

90 }

public void s e tMf i e ldTarge t ( Mf ie ld mf ie ldTarget ) {this . mf ie ldTarget = mf ie ldTarget ;

}

@Override

public int hashCode ( ) {f ina l int prime = 31 ;

int r e s u l t = 1 ;

100 r e s u l t = prime ∗ r e s u l t + r e l a t i o n I d ;

return r e s u l t ;

}

@Override

public boolean equa l s ( Object obj ) {i f ( this == obj )

return true ;

i f ( obj == null )

return fa l se ;

110 i f ( ge tC la s s ( ) != obj . g e tC la s s ( ) )

return fa l se ;

Re la t ion other = ( Re lat ion ) obj ;

i f ( r e l a t i o n I d != other . r e l a t i o n I d )

return fa l se ;

return true ;

}

@Override

public int compareTo ( Re lat ion arg0 ) {120 i f ( g e tRe la t i on Id ( ) < arg0 . g e tRe la t i on Id ( ) )

return −1 ;

i f ( g e tRe la t i on Id ( ) > arg0 . g e tRe la t i on Id ( ) )

return 1 ;

return 0 ;

}

}

D.5.28 Classe Role.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

import java . u t i l . L i s t ;

@Entity

367

Page 386: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Table (name = ” r o l e ” )

public class Role implements S e r i a l i z a b l e {10 private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

@Column(name = ”ROLE ID” )

private int r o l e I d ;

@Column(name = ”CODE” )

private St r ing code ;

20 @Column(name = ”ROLE DESCRIPTION” )

private St r ing r o l e D e s c r i p t i o n ;

@OneToMany(mappedBy = ” r o l e ” )

private List<Assignment> ass ignments ;

public Role ( ) {}

30 public int getRole Id ( ) {return this . r o l e I d ;

}

public void s e tRo l e Id ( int r o l e I d ) {this . r o l e I d = r o l e I d ;

}

public St r ing getCode ( ) {return this . code ;

40 }

public void setCode ( S t r ing code ) {this . code = code ;

}

public St r ing ge tRo l eDesc r ip t i on ( ) {return this . r o l e D e s c r i p t i o n ;

}

50 public void s e tRo l eDe s c r i p t i on ( St r ing r o l e D e s c r i p t i o n ) {this . r o l e D e s c r i p t i o n = r o l e D e s c r i p t i o n ;

}

public List<Assignment> getAssignments ( ) {return this . ass ignments ;

}

public void setAss ignments ( L is t<Assignment> ass ignments ) {this . ass ignments = ass ignments ;

60 }

@Override

368

Page 387: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public int hashCode ( ) {f ina l int prime = 31 ;

int r e s u l t = 1 ;

r e s u l t = prime ∗ r e s u l t + ( ( code == null ) ? 0 : code . hashCode ( ) ) ;

r e s u l t = prime ∗ r e s u l t

+ ( ( r o l e D e s c r i p t i o n == null ) ? 0 : r o l e D e s c r i p t i o n . hashCode ( ) ) ;

70 r e s u l t = prime ∗ r e s u l t + r o l e I d ;

return r e s u l t ;

}

@Override

public boolean equa l s ( Object obj ) {i f ( this == obj ) {

return true ;

}i f ( obj == null ) {

80 return fa l se ;

}i f ( ! ( obj instanceof Role ) ) {

return fa l se ;

}Role other = ( Role ) obj ;

i f ( code == null ) {i f ( other . code != null ) {

return fa l se ;

}90 } else i f ( ! code . equa l s ( other . code ) ) {

return fa l se ;

}i f ( r o l e D e s c r i p t i o n == null ) {

i f ( other . r o l e D e s c r i p t i o n != null ) {return fa l se ;

}} else i f ( ! r o l e D e s c r i p t i o n . equa l s ( other . r o l e D e s c r i p t i o n ) ) {

return fa l se ;

}100 i f ( r o l e I d != other . r o l e I d ) {

return fa l se ;

}return true ;

}

public St r ing toS t r i ng ( ) {return r o l e D e s c r i p t i o n ;

}}

D.5.29 Classe RuleExclusion.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

369

Page 388: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Entity

@Table (name = ” r u l e e x c l u s i o n ” )

public class RuleExclus ion implements S e r i a l i z a b l e {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

10@Id

@GeneratedValue ( s t r a t e g y = GenerationType . IDENTITY)

@Column(name = ”RULE EXCLUSION ID” )

private int ru l eExc lu s i on Id ;

@ManyToOne

@JoinColumn (name = ”TARGET ANSWER ID” )

private Alternat iveAnswer a l te rnat iveAnswerTarget ;

20 @ManyToOne

@JoinColumn (name = ”SOURCE ANSWER ID” )

private Alternat iveAnswer a l te rnat iveAnswerSource ;

@ManyToOne

@JoinColumn (name = ”TARGET QUESTION ID” )

private Question ques t i on ;

@Transient

private St r ing q ue s t i o n S t r i n g ;

30@Column(name = ”SIL” )

private Boolean s i l ;

public RuleExclus ion ( ) {}

public int getRuleExc lus ionId ( ) {return this . r u l eExc lu s i on Id ;

}40

public void s e tRu leExc lus ion Id ( int ru l eExc lu s i on Id ) {this . r u l eExc lu s i on Id = ru l eExc lu s i on Id ;

}

public Alternat iveAnswer getAlternat iveAnswerTarget ( ) {return this . a l te rnat iveAnswerTarget ;

}

public void setAlternat iveAnswerTarget (

50 Alternat iveAnswer a l te rnat iveAnswerTarget ) {this . a l t e rnat iveAnswerTarget = al ternat iveAnswerTarget ;

}

public Alternat iveAnswer getAlternat iveAnswerSource ( ) {return this . a l t e rnat iveAnswerSource ;

}

public void se tAlternat iveAnswerSource (

Alternat iveAnswer a l te rnat iveAnswerSource ) {60 this . a l t e rnat iveAnswerSource = al te rnat iveAnswerSource ;

}

370

Page 389: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public Question getQuest ion ( ) {return this . que s t i on ;

}

public void se tQuest ion ( Question ques t i on ) {this . ques t i on = ques t i on ;

}70

public void s e t S i l ( Boolean s i l ) {this . s i l = s i l ;

}

public Boolean g e t S i l ( ) {return s i l ;

}

public void s e tQues t i onSt r ing ( S t r ing q u e s t i o n S t r i n g ) {80 this . q u e s t i o nS t r i n g = q u e s t i o n S t r i n g ;

}

public St r ing getQues t i onSt r ing ( ) {i f ( a l te rnat iveAnswerTarget == null | | a l ternat iveAnswerTarget . getQuest ion ( )

== null )

return null ;

return a l ternat iveAnswerTarget . getQuest ion ( ) . getQuest ion ( ) ;

}

}

D.5.30 Classe RuleMulteplicity.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import javax . p e r s i s t e n c e . ∗ ;

@Entity

@Table (name=” r u l e m u l t e p l i c i t y ” )

public class RuleMul t ep l i c i ty implements S e r i a l i z a b l e {10 private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

@Column(name=”RULE MULTEPLICITY ID” )

private int r u l e M u l t e p l i c i t y I d ;

@Column(name=”LOWEBOUND” )

private int lowebound ;

20 @Column(name=”TYPE” )

private St r ing type ;

371

Page 390: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Column(name=”UPPERBOUND” )

private int upperbound ;

@ManyToOne

@JoinColumn (name=”ANSWER ID” )

private Alternat iveAnswer a l t e rnat iveAnswer ;

30 @ManyToOne

@JoinColumn (name=”QUESTION ID” )

private Question ques t i on ;

public RuleMul t ep l i c i ty ( ) {}

public int ge tRu l eMu l t ep l i c i t y Id ( ) {return this . r u l e M u l t e p l i c i t y I d ;

}40

public void s e t R u l e M u l t e p l i c i t y I d ( int r u l e M u l t e p l i c i t y I d ) {this . r u l e M u l t e p l i c i t y I d = r u l e M u l t e p l i c i t y I d ;

}

public int getLowebound ( ) {return this . lowebound ;

}

public void setLowebound ( int lowebound ) {50 this . lowebound = lowebound ;

}

public St r ing getType ( ) {return this . type ;

}

public void setType ( S t r ing type ) {this . type = type ;

}60

public int getUpperbound ( ) {return this . upperbound ;

}

public void setUpperbound ( int upperbound ) {this . upperbound = upperbound ;

}

public Alternat iveAnswer getAlternat iveAnswer ( ) {70 return this . a l t e rnat iveAnswer ;

}

public void se tAlternat iveAnswer ( Alternat iveAnswer a l t e rnat iveAnswer ) {this . a l t e rnat iveAnswer = al te rnat iveAnswer ;

}

public Question getQuest ion ( ) {return this . que s t i on ;

372

Page 391: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}80

public void se tQuest ion ( Question ques t i on ) {this . ques t i on = ques t i on ;

}

}

D.5.31 Classe User.java

package i t . uniroma2 . norge . model . jpa ;

import java . i o . S e r i a l i z a b l e ;

import java . u t i l . L i s t ;

import javax . p e r s i s t e n c e . Column ;

import javax . p e r s i s t e n c e . Entity ;

import javax . p e r s i s t e n c e . GeneratedValue ;

import javax . p e r s i s t e n c e . GenerationType ;

10 import javax . p e r s i s t e n c e . Id ;

import javax . p e r s i s t e n c e . JoinColumn ;

import javax . p e r s i s t e n c e . ManyToOne ;

import javax . p e r s i s t e n c e . OneToMany ;

import javax . p e r s i s t e n c e . Table ;

@Entity

@Table (name=” user ” )

public class User implements S e r i a l i z a b l e {20 private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Id

@GeneratedValue ( s t r a t e g y=GenerationType . IDENTITY)

@Column(name=”USER ID” )

private int use r Id ;

@Column(name=”NAME” )

private St r ing name ;

30 @Column(name=”PASSWORD” )

private St r ing password ;

@Column(name=”PASSWORDCHECK” )

private St r ing passwordcheck ;

@Column(name=”USER” )

private St r ing user ;

@OneToMany(mappedBy=” user ” )

40 private List<Assignment> ass ignments ;

@OneToMany(mappedBy=” f i l l U s e r ” )

private List<Evidence> f i l l A n s w e r ;

373

Page 392: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@OneToMany(mappedBy=” approvUser ” )

private List<Evidence> approvAnswer ;

@ManyToOne

@JoinColumn (name=” o r g a n i z a t i o n i d ” )

50 private Organizat ion o r g a n i z a t i o n ;

public User ( ) {}

public int getUserId ( ) {return this . u s e r Id ;

}

public void s e tUser Id ( int use r Id ) {60 this . u s e r Id = user Id ;

}

public St r ing getName ( ) {return this . name ;

}

public void setName ( St r ing name) {this . name = name ;

}70

public St r ing getPassword ( ) {return this . password ;

}

public void setPassword ( St r ing password ) {this . password = password ;

}

public St r ing getPasswordcheck ( ) {80 return this . passwordcheck ;

}

public void setPasswordcheck ( St r ing passwordcheck ) {this . passwordcheck = passwordcheck ;

}

public St r ing getUser ( ) {return this . u se r ;

}90

public void se tUser ( S t r ing user ) {this . u se r = user ;

}

public List<Assignment> getAssignments ( ) {return this . ass ignments ;

}

public void setAss ignments ( L is t<Assignment> ass ignments ) {100 this . ass ignments = ass ignments ;

374

Page 393: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

public List<Evidence> getF i l lAnswer ( ) {return this . f i l l A n s w e r ;

}

public void s e tF i l lAnswer ( Li s t<Evidence> f i l l A n s w e r ) {this . f i l l A n s w e r = f i l l A n s w e r ;

}110

public List<Evidence> getApprovAnswer ( ) {return this . approvAnswer ;

}

public void setApprovAnswer ( Lis t<Evidence> approvAnswer ) {this . approvAnswer = approvAnswer ;

}

@Override

120 public int hashCode ( ) {f ina l int prime = 31 ;

int r e s u l t = 1 ;

r e s u l t = prime ∗ r e s u l t + ( ( name == null ) ? 0 : name . hashCode ( ) ) ;

r e s u l t = prime ∗ r e s u l t + ( ( user == null ) ? 0 : user . hashCode ( ) ) ;

r e s u l t = prime ∗ r e s u l t + use r Id ;

return r e s u l t ;

}

@Override

130 public boolean equa l s ( Object obj ) {i f ( this == obj ) {

return true ;

}i f ( obj == null ) {

return fa l se ;

}i f ( ! ( obj instanceof User ) ) {

return fa l se ;

}140 User other = ( User ) obj ;

i f (name == null ) {i f ( other . name != null ) {

return fa l se ;

}} else i f ( ! name . equa l s ( other . name) ) {

return fa l se ;

}i f ( user == null ) {

i f ( other . user != null ) {150 return fa l se ;

}} else i f ( ! use r . equa l s ( other . user ) ) {

return fa l se ;

}i f ( use r Id != other . u se r Id ) {

return fa l se ;

375

Page 394: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}return true ;

}160

public St r ing toS t r i ng ( ) {return name ;

}

public void s e tOrgan i za t i on ( Organizat ion o r ga n i z a t i o n ) {this . o r g a n i z a t i o n = o r g an i z a t i o n ;

}

public Organizat ion getOrgan izat ion ( ) {170 return o r g a n i z a t i o n ;

}

}

D.6 Package it.uniroma2.norge.web

D.6.1 Classe AgreementUI.java

package i t . uniroma2 . norge . web ;

import i t . uniroma2 . norge . c o n t r o l l e r . Ass ignmentsCtr l ;

import i t . uniroma2 . norge . c o n t r o l l e r . AgreementCtrl ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . AgreementFieldFactory ;

import java . u t i l . Arrays ;

10 import java . u t i l . L i s t ;

import com . vaadin . data . u t i l . BeanItem ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . t e rmina l . S i z e a b l e ;

import com . vaadin . u i . Alignment ;

import com . vaadin . u i . Button ;

import com . vaadin . u i . Form ;

import com . vaadin . u i . GridLayout ;

import com . vaadin . u i . Hor izonta lLayout ;

20 import com . vaadin . u i . Panel ;

import com . vaadin . u i . Table ;

import com . vaadin . u i . Vert i ca lLayout ;

import com . vaadin . u i . Button . Cl ickEvent ;

import com . vaadin . u i . Window . N o t i f i c a t i o n ;

public class AgreementUI {

private TesiwebAppl icat ion a p p l i c a t i o n ;

30 private AgreementCtrl c t r l P r j ;

376

Page 395: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private AssignmentsCtr l c t r lAss ignment ;

private Vert i ca lLayout body ;

private GridLayout pro jectGr idL ;

private BeanItemContainer<Agreement> pro ject sDataSource ;

40 public Table p ro j e c t sTab l e ;

public AgreementUI ( Tes iwebAppl icat ion appl ) {this . a p p l i c a t i o n = appl ;

c t r l P r j = a p p l i c a t i o n . g e tCt r lP r j ( ) ;

c t r lAss ignment = a p p l i c a t i o n . getCtr lAss ignment ( ) ;

body = a p p l i c a t i o n . getBody ( ) ;

}

public void p r o j e c t s L i s t ( ) {50 c t r l P r j = a p p l i c a t i o n . g e tCt r lP r j ( ) ;

a p p l i c a t i o n . setArea ( ”” ) ;

body . removeAllComponents ( ) ;

Panel p = new Panel ( ”” ) ;

p . setWidth (95 , S i z e a b l e .UNITS PERCENTAGE) ;

pro jectGr idL = new GridLayout (2 , 1) ;

pro jectGr idL . se tSpac ing ( true ) ;

pro jectGr idL . setMargin ( true ) ;

pro jectGr idL . s e t S i z e F u l l ( ) ;

pro jectGr idL . addComponent (p , 0 , 0) ;

60 body . addComponent ( pro jectGr idL ) ;

body . setComponentAlignment ( projectGridL , Alignment .TOP LEFT) ;

p ro j e c t sTab l e = new Table ( ) ;

p ro j e c t sTab l e . s e t S e l e c t a b l e ( true ) ;

p ro j e c t sTab l e . setImmediate ( true ) ;

p ro j e c t sTab l e . addLis tener ( a p p l i c a t i o n . g e tCt r lP r j ( ) ) ;

L i s t<Agreement> datas = c t r l P r j . getL is tData ( ) ;

i f ( datas . s i z e ( ) > 0) {pro ject sDataSource = new BeanItemContainer<Agreement>(datas ) ;

70 pro j e c t sTab l e . setContainerDataSource ( pro jec t sDataSource ) ;

p ro j e c t sTab l e . setVis ib leColumns (new Object [ ] { ”name” , ” q u e s t i o n n a i r e ” }) ;

p ro j e c t sTab l e . setColumnHeaders (new St r ing [ ] { ”Agreement name” ,

” Quest ionna i re ” }) ;

p ro j e c t sTab l e . setColumnReorderingAllowed ( fa l se ) ;

p ro j e c t sTab l e . setColumnCollapsingAllowed ( fa l se ) ;

p ro j e c t sTab l e . setPageLength (10) ;

}p . addComponent ( p ro j e c t sTab l e ) ;

Button btnAddQuestion = new Button ( ”Add new agreement ” ,

new Button . C l i c k L i s t e n e r ( ) {80 public void buttonCl ick ( ClickEvent event ) {

projectsAdd ( ) ;

}}) ;

p . addComponent ( btnAddQuestion ) ;

}

377

Page 396: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void projectsAdd ( ) {c t r l P r j = a p p l i c a t i o n . g e tCt r lP r j ( ) ;

a p p l i c a t i o n . setArea ( ” Create a new agreement . . . ” ) ;

90 body . removeAllComponents ( ) ;

f ina l Panel p = new Panel ( ”New agreement ” ) ;

p . s e tS i z eUnde f ined ( ) ;

body . addComponent (p) ;

body . setComponentAlignment (p , Alignment .TOP CENTER) ;

f ina l Agreement p r j = new Agreement ( ) ;

p r j . setName ( ”” ) ;

BeanItem<Agreement> prj I tem = new BeanItem<Agreement>( p r j ) ;

100 f ina l Form addingForm = new Form ( ) ;

addingForm . setWriteThrough ( fa l se ) ;

addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new

AgreementFieldFactory ( a p p l i c a t i o n . g e tCt r lOrgan i za t i on s ( ) . ge tOrgan i za t i ons ( ) ) ) ;

addingForm . setItemDataSource ( pr j I tem ) ;

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”name” , ” q u e s t i o n n a i r e ” , ” o r g a n i z a t i o n S u p p l i e r ” , ” o r g a n i z a t i o n C e r t i f i e r ”

}) ) ;

110 Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {addingForm . commit ( ) ;

a p p l i c a t i o n . g e tCt r lP r j ( ) . c r e a t e ( p r j ) ;

p . getWindow ( ) . showNot i f i c a t i on ( ” Conf irmation ” , ”<br/>” ,

N o t i f i c a t i o n .TYPE TRAY NOTIFICATION) ;

} catch ( SaveException e ) {p . getWindow ( ) . showNot i f i c a t i on ( ” Error ” ,

”<br/>” + e . t oS t r i ng ( ) ,

120 N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}}

}) ;

p . addComponent ( addingForm ) ;

p . addComponent ( apply ) ;

}

130 public void p r o j e c t D e t a i l s ( ) {c t r l P r j = a p p l i c a t i o n . g e tCt r lP r j ( ) ;

c t r lAss ignment = a p p l i c a t i o n . getCtr lAss ignment ( ) ;

f ina l Agreement p r j = ( Agreement ) p ro j e c t sTab l e . getValue ( ) ;

f ina l Panel p = new Panel ( ”Agreement d e t a i l s ” ) ;

p . s e tS i z eUnde f ined ( ) ;

f ina l Panel po = new Panel ( ” Operat ions ” ) ;

po . s e tS i z eUnde f ined ( ) ;

Hor izonta lLayout h = new Horizonta lLayout ( ) ;

po . setContent (h) ;

378

Page 397: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

140 Vert i ca lLayout vertL = new Vert i ca lLayout ( ) ;

vertL . addComponent (p) ;

vertL . addComponent ( po ) ;

pro jectGr idL . removeComponent (1 , 0) ;

pro jectGr idL . addComponent ( vertL , 1 , 0) ;

BeanItem<Agreement> prj I tem = pro ject sDataSource . getItem ( pr j ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

150 modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm . setFormFieldFactory (new AgreementFieldFactory ( prj ,

a p p l i c a t i o n . g e tCt r lOrgan i za t i on s ( ) . ge tOrgan i za t i ons ( ) ) ) ;

modifyForm . setItemDataSource ( pr j I tem ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”name” , ”model” , ” o r g a n i z a t i o n S u p p l i e r ” , ” o r g a n i z a t i o n C e r t i f i e r ” }) ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {modifyForm . commit ( ) ;

160 c t r l P r j . update ( p r j ) ;

p . getWindow ( ) . showNot i f i c a t i on ( ” Conf irmation ” , ”<br/>” ,

N o t i f i c a t i o n .TYPE TRAY NOTIFICATION) ;

p ro j e c t sTab l e . r eques tRepa intAl l ( ) ;

} catch ( SaveException e ) {p . getWindow ( ) . showNot i f i c a t i on ( ” Error ” ,

”<br/>” + e . t oS t r i ng ( ) ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}}

170 }) ;

Button d i s ca rd = new Button ( ” Discard ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

modifyForm . d i s ca rd ( ) ;

}}) ;

Button btnUsers = new Button ( ” Users l i s t ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

ctr lAss ignment . v iewAl l ( p r j ) ;

}180 }) ;

p . addComponent ( modifyForm ) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent ( d i s ca rd ) ;

p . addComponent ( btnLayout ) ;

po . addComponent ( btnUsers ) ;

}

190 }

379

Page 398: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.6.2 Classe AssignmentUI.java

package i t . uniroma2 . norge . web ;

import i t . uniroma2 . norge . c o n t r o l l e r . Ass ignmentsCtr l ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . c o n t r o l l e r . User sCtr l ;

import i t . uniroma2 . norge . model . jpa . Assignment ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . Ass ignmentFie ldFactory ;

import java . u t i l . Arrays ;

10 import java . u t i l . L i s t ;

import com . vaadin . data . u t i l . BeanItem ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . t e rmina l . S i z e a b l e ;

import com . vaadin . u i . Alignment ;

import com . vaadin . u i . Button ;

import com . vaadin . u i . Form ;

import com . vaadin . u i . GridLayout ;

import com . vaadin . u i . Hor izonta lLayout ;

20 import com . vaadin . u i . Panel ;

import com . vaadin . u i . Table ;

import com . vaadin . u i . Vert i ca lLayout ;

import com . vaadin . u i . Button . Cl ickEvent ;

import com . vaadin . u i . Window . N o t i f i c a t i o n ;

public class AssignmentUI

{

private TesiwebAppl icat ion a p p l i c a t i o n ;

30private AssignmentsCtr l c t r lAss ignments ;

private Vert i ca lLayout body ;

private GridLayout assignmentGridL ;

private BeanItemContainer<Assignment> ass ignmentsDataSource ;

public Table assignmentTable ;

40private UsersCtr l c t r l U s e r s ;

public AssignmentUI ( Tes iwebAppl icat ion appl )

{this . a p p l i c a t i o n = appl ;

c t r lAss ignments = a p p l i c a t i o n . getCtr lAss ignment ( ) ;

body = a p p l i c a t i o n . getBody ( ) ;

}

50 public void ass ignmentL i s t ( )

{c t r lAss ignments = a p p l i c a t i o n . getCtr lAss ignment ( ) ;

a p p l i c a t i o n . setArea ( ”” ) ;

body . removeAllComponents ( ) ;

380

Page 399: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

Panel p = new Panel ( ”” ) ;

p . setWidth (95 , S i z e a b l e .UNITS PERCENTAGE) ;

assignmentGridL = new GridLayout (2 , 2) ;

assignmentGridL . se tSpac ing ( true ) ;

assignmentGridL . setMargin ( true ) ;

60 assignmentGridL . s e t S i z e F u l l ( ) ;

assignmentGridL . addComponent (p , 0 , 0) ;

body . addComponent ( assignmentGridL ) ;

body . setComponentAlignment ( assignmentGridL , Alignment .TOP LEFT) ;

ass ignmentTable = new Table ( ) ;

ass ignmentTable . s e t S e l e c t a b l e ( true ) ;

ass ignmentTable . setImmediate ( true ) ;

ass ignmentTable . addLis tener ( c t r lAss ignments . getAss ignmentSe lected ( ) ) ;

L i s t<Assignment> datas = ctr lAss ignments . getL is tData ( ) ;

70 i f ( datas . s i z e ( ) > 0 )

{ass ignmentsDataSource = new BeanItemContainer<Assignment>(datas ) ;

ass ignmentTable . setContainerDataSource ( ass ignmentsDataSource ) ;

ass ignmentTable . se tVis ib leColumns (new Object [ ] {” user ” , ” r o l e ” }) ;

ass ignmentTable . setColumnHeaders (new St r ing [ ] {”User” , ”Role” }) ;

ass ignmentTable . setColumnReorderingAllowed ( fa l se ) ;

ass ignmentTable . setColumnCollapsingAllowed ( fa l se ) ;

ass ignmentTable . setPageLength (5 ) ;

p . addComponent ( ass ignmentTable ) ;

80 } else {p . getWindow ( ) . showNot i f i c a t i on ( ”No datas ” , ”<br/>There aren ’ t any

que s t i on s f o r t h i s p r o j e c t . ” +

”<br/><br/>You can add a new ques t i on by c l i c k i n g the button . ” ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}Button btnAddAssignment = new Button ( ”Add assignment ” , new

Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getCtr lAss ignment ( ) . addAssignment ( ) ;

}}) ;

p . addComponent ( btnAddAssignment ) ;

90 }

public void as s i gnmentDeta i l s ( )

{c t r lAss ignments = a p p l i c a t i o n . getCtr lAss ignment ( ) ;

c t r l U s e r s = a p p l i c a t i o n . ge tCtr lUser ( ) ;

f ina l Assignment a = ( Assignment ) ass ignmentTable . getValue ( ) ;

f ina l Panel p = new Panel ( ”Assignment d e t a i l s ” ) ;

p . s e tS i z eUnde f ined ( ) ;

Vert i ca lLayout vertL = new Vert i ca lLayout ( ) ;

100 vertL . s e t S i z e F u l l ( ) ;

vertL . addComponent (p) ;

assignmentGridL . removeComponent (1 , 0) ;

assignmentGridL . addComponent ( vertL , 1 , 0) ;

BeanItem<Assignment> ass ignI tem = assignmentsDataSource . getItem ( a ) ;

f ina l Form modifyForm = new Form ( ) ;

381

Page 400: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

110AssignmentFie ldFactory tmp = new AssignmentFie ldFactory ( a ) ;

tmp . setUserDs ( c t r l U s e r s . getL is tData ( ) ) ;

tmp . setRoleDs ( c t r lAss ignments . getRo le s ( ) ) ;

modifyForm . setFormFieldFactory (tmp) ;

modifyForm . setItemDataSource ( as s ignI tem ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {” user ” , ” r o l e ” }) ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

120 try {modifyForm . commit ( ) ;

a p p l i c a t i o n . getCtr lAss ignment ( ) . update ( a ) ;

p . getWindow ( ) . showNot i f i c a t i on ( ” Conf irmation ” , ”<br/>” ,

N o t i f i c a t i o n .TYPE TRAY NOTIFICATION) ;

ass ignmentTable . r eques tRepa intAl l ( ) ;

} catch ( SaveException e ) {p . getWindow ( ) . showNot i f i c a t i on ( ” Error ” , ”<br/>”+e . t oS t r i ng ( ) ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}}

}) ;

130 Button d i s ca rd = new Button ( ” Discard ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

modifyForm . d i s ca rd ( ) ;

}}) ;

p . addComponent ( modifyForm ) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent ( d i s ca rd ) ;

140 p . addComponent ( btnLayout ) ;

}

public void assignmentAdd ( )

{c t r lAss ignments = a p p l i c a t i o n . getCtr lAss ignment ( ) ;

c t r l U s e r s = a p p l i c a t i o n . ge tCtr lUser ( ) ;

f ina l Panel p = new Panel ( ”” ) ;

p . s e tS i z eUnde f ined ( ) ;

Vert i ca lLayout vertL = new Vert i ca lLayout ( ) ;

150 vertL . addComponent (p) ;

assignmentGridL . removeComponent (1 , 0) ;

assignmentGridL . addComponent ( vertL , 1 , 0) ;

f ina l Assignment a = new Assignment ( ) ;

BeanItem<Assignment> ass ignI tem = new BeanItem<Assignment>(a ) ;

Ass ignmentFie ldFactory tmp = new AssignmentFie ldFactory ( ) ;

tmp . setUserDs ( c t r l U s e r s . getL is tData ( ) ) ;

tmp . setRoleDs ( c t r lAss ignments . getRo le s ( ) ) ;

160 f ina l Form addingForm = new Form ( ) ;

addingForm . setWriteThrough ( fa l se ) ;

382

Page 401: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (tmp) ;

addingForm . setItemDataSource ( as s ignI tem ) ;

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ]

{” user ” , ” r o l e ” }) ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {addingForm . commit ( ) ;

170 a p p l i c a t i o n . getCtr lAss ignment ( ) . c r e a t e ( a ) ;

} catch ( SaveException e ) {}

}}) ;

p . addComponent ( addingForm ) ;

p . addComponent ( apply ) ;

}

180}

D.6.3 Classe DefaultDeliverablesUI.java

package i t . uniroma2 . norge . web ;

import i t . uniroma2 . norge . c o n t r o l l e r . De fDe l i v e r ab l eCt r l ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . DelivCategManager ;

import i t . uniroma2 . norge . model . jpa . D e f a u l t D e l i v e r a b l e ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . De f au l tDe l i v e rab l eF i e l dFac to ry ;

import java . u t i l . Arrays ;

10 import java . u t i l . L i s t ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . data . u t i l . BeanItem ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . t e rmina l . S i z e a b l e ;

import com . vaadin . u i . Alignment ;

import com . vaadin . u i . Button ;

import com . vaadin . u i . Form ;

20 import com . vaadin . u i . GridLayout ;

import com . vaadin . u i . Hor izonta lLayout ;

import com . vaadin . u i . Panel ;

import com . vaadin . u i . Table ;

import com . vaadin . u i . Vert i ca lLayout ;

import com . vaadin . u i . Button . Cl ickEvent ;

public class Defau l tDe l i v e rab l e sUI {

private TesiwebAppl icat ion a p p l i c a t i o n ;

30

383

Page 402: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private De fDe l i v e r ab l eCt r l c t r l D e l i v s ;

private Vert i ca lLayout body ;

private GridLayout de l ivGr idL ;

private BeanItemContainer<Defau l tDe l i v e rab l e> de l ivDataSource ;

public Table de l i v sTab l e ;

40public Defau l tDe l i v e rab l e sUI ( Tes iwebAppl icat ion appl ) {

this . a p p l i c a t i o n = appl ;

c t r l D e l i v s = a p p l i c a t i o n . g e t C t r l D e f D e l i v e r a b l e s ( ) ;

body = a p p l i c a t i o n . getBody ( ) ;

}

public void d e l i v e r a b l e s L i s t A l l ( ) {c t r l D e l i v s = a p p l i c a t i o n . g e t C t r l D e f D e l i v e r a b l e s ( ) ;

a p p l i c a t i o n . setArea ( ”” ) ;

50 body . removeAllComponents ( ) ;

Vert i ca lLayout p = new Vert i ca lLayout ( ) ;

p . s e t S i z e F u l l ( ) ;

de l ivGr idL = new GridLayout (1 , 2) ;

de l ivGr idL . se tSpac ing ( true ) ;

de l ivGr idL . setMargin ( true ) ;

de l ivGr idL . s e t S i z e F u l l ( ) ;

de l ivGr idL . addComponent (p , 0 , 0) ;

body . addComponent ( de l ivGr idL ) ;

body . setComponentAlignment ( del ivGridL , Alignment .TOP LEFT) ;

60de l i v sTab l e = new Table ( ) ;

d e l i v sTab l e . setWidth (98 , S i z e a b l e .UNITS PERCENTAGE) ;

de l i v sTab l e . s e t S e l e c t a b l e ( true ) ;

d e l i v sTab l e . setImmediate ( true ) ;

d e l i v sTab l e . addLis tener ( c t r l D e l i v s ) ;

d e l i v sTab l e . addLis tener (new Property . ValueChangeListener ( ) {@Override

public void valueChange ( ValueChangeEvent event ) {Object x = de l i v sTab l e . getValue ( ) ;

70 i f ( x != null ) {d e l i v D e t a i l s ( ( D e f a u l t D e l i v e r a b l e ) de l i v sTab l e . getValue ( ) ) ;

i f ( de l ivDataSource != null

&& del ivDataSource . get I temIds ( ) != null ) {for ( D e f a u l t D e l i v e r a b l e d : de l ivDataSource

. get I temIds ( ) ) {c t r l D e l i v s . r e f r e s h ( de l ivDataSource . getItem (d)

. getBean ( ) ) ;

}}

80 Object [ ] v i s ib leColumns = de l i v sTab l e . getVis ib leColumns ( ) ;

d e l i v sTab l e . setContainerDataSource ( de l ivDataSource ) ;

d e l i v sTab l e . setVis ib leColumns ( v i s ib leColumns ) ;

d e l i v sTab l e . r eques tRepa intAl l ( ) ;

de l ivGr idL . r eques tRepa intAl l ( ) ;

}}

384

Page 403: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}) ;

L i s t<Defau l tDe l i v e rab l e> datas = c t r l D e l i v s . getL is tData ( ) ;

i f ( datas . s i z e ( ) > 0) {90 de l ivDataSource = new BeanItemContainer<Defau l tDe l i v e rab l e >(datas ) ;

d e l i v sTab l e . setContainerDataSource ( de l ivDataSource ) ;

d e l i v sTab l e . setVis ib leColumns (new Object [ ] { ” de l ivCateg ” ,

” de l ivSubcateg ” , ”name” , ” d e s c r i p t i o n ” , ” type ” , ” subtype1 ” ,

” subtype2 ” }) ;

d e l i v sTab l e . setColumnHeaders (new St r ing [ ] { ” Category ” ,

” Subcategory ” , ”Name” , ” Desc r ip t i on ” , ”” , ”” , ”” }) ;

d e l i v sTab l e . setColumnReorderingAllowed ( true ) ;

d e l i v sTab l e . setColumnCollapsingAllowed ( true ) ;

d e l i v sTab l e . setPageLength (10) ;

100 }p . addComponent ( de l i v sTab l e ) ;

Button btnAddQuestion = new Button ( ”Add new d e l i v e r a b l e ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

delivAdd ( ) ;

}}) ;

p . addComponent ( btnAddQuestion ) ;

de l ivGr idL . r eques tRepa intAl l ( ) ;

110 }

public void delivAdd ( ) {c t r l D e l i v s = a p p l i c a t i o n . g e t C t r l D e f D e l i v e r a b l e s ( ) ;

DelivCategManager categMngr = new DelivCategManager ( ) ;

a p p l i c a t i o n . setArea ( ” Create a new user . . . ” ) ;

body . removeAllComponents ( ) ;

f ina l Panel p = new Panel ( ”New d e l i v e r a b l e ” ) ;

p . s e tS i z eUnde f ined ( ) ;

body . addComponent (p) ;

120 body . setComponentAlignment (p , Alignment .TOP CENTER) ;

f ina l D e f a u l t D e l i v e r a b l e d = new D e f a u l t D e l i v e r a b l e ( ) ;

d . setName ( ”” ) ;

d . s e t D e s c r i p t i o n ( ”” ) ;

BeanItem<Defau l tDe l i v e rab l e> delItem = new BeanItem<Defau l tDe l i v e rab l e >(

d) ;

f ina l Form addingForm = new Form ( ) ;

addingForm . setWriteThrough ( fa l se ) ;

130 addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new De fau l tDe l i v e r ab l eF i e l dFac to ry (d ,

categMngr . viewAllCateg ( ) ) ) ;

addingForm . setItemDataSource ( de l Item ) ;

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”name” , ” d e s c r i p t i o n ” , ” de l ivCateg ” , ” de l ivSubcateg ” , ” type ” ,

” subtype1 ” , ” subtype2 ” }) ) ;

140 Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {

385

Page 404: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

addingForm . commit ( ) ;

c t r l D e l i v s . c r e a t e (d) ;

} catch ( SaveException e ) {a p p l i c a t i o n . showNot i f i c a t i on ( ” Error ” ) ;

}}

}) ;

150p . addComponent ( addingForm ) ;

p . addComponent ( apply ) ;

}

public void d e l i v D e t a i l s ( D e f a u l t D e l i v e r a b l e d e f a u l t D e l i v e r a b l e ) {c t r l D e l i v s = a p p l i c a t i o n . g e t C t r l D e f D e l i v e r a b l e s ( ) ;

c t r l D e l i v s . r e f r e s h ( d e f a u l t D e l i v e r a b l e ) ;

DelivCategManager categMngr = new DelivCategManager ( ) ;

160 i f ( de l i v sTab l e == null ) {System . out . p r i n t l n ( ” Tabel la non e s i s t e ” ) ;

return ;

}i f ( de l i v sTab l e . getValue ( ) == null )

System . out . p r i n t l n ( ”Elemento non e s i s t e ” ) ;

f ina l D e f a u l t D e l i v e r a b l e d e l i = d e f a u l t D e l i v e r a b l e ;

f ina l Panel p = new Panel ( ” D e t a i l s ” ) ;

p . s e tS i z eUnde f ined ( ) ;

Vert i ca lLayout vertL = new Vert i ca lLayout ( ) ;

170 vertL . s e tS i z eUnde f ined ( ) ;

vertL . addComponent (p) ;

de l ivGr idL . removeComponent (0 , 1) ;

de l ivGr idL . addComponent ( vertL , 0 , 1) ;

de l ivGr idL . setComponentAlignment ( vertL , Alignment .TOP CENTER) ;

BeanItem<Defau l tDe l i v e rab l e> delItem = del ivDataSource . getItem ( d e l i ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

180 modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm . setFormFieldFactory (new De fau l tDe l i v e r ab l eF i e l dFac to ry ( d e l i ,

categMngr . viewAllCateg ( ) ) ) ;

modifyForm . setItemDataSource ( de l Item ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”name” , ” d e s c r i p t i o n ” , ” de l ivCateg ” , ” de l ivSubcateg ” , ” type ” ,

” subtype1 ” , ” subtype2 ” }) ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

190 try {modifyForm . commit ( ) ;

c t r l D e l i v s . update ( d e l i ) ;

d e l i v sTab l e . r eques tRepa intAl l ( ) ;

de l ivGr idL . r eques tRepa intAl l ( ) ;

} catch ( SaveException e ) {a p p l i c a t i o n . showNot i f i c a t i on ( ” Error ” ) ;

}}

386

Page 405: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}) ;

200 Button d i s ca rd = new Button ( ” Discard ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

modifyForm . d i s ca rd ( ) ;

}}) ;

p . addComponent ( modifyForm ) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent ( d i s ca rd ) ;

210 p . addComponent ( btnLayout ) ;

}

}

D.6.4 Classe DeliverablesUI.java

package i t . uniroma2 . norge . web ;

import i t . uniroma2 . norge . c o n t r o l l e r . D e l i v e r a b l e C t r l ;

import i t . uniroma2 . norge . c o n t r o l l e r . LoggedUser ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . c o n t r o l l e r . D e l i v e r a b l e C t r l . De l ivAct ions ;

import i t . uniroma2 . norge . model . DelivCategManager ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

import i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e ;

10 import i t . uniroma2 . norge . model . jpa . De l ive rab l eEv idence ;

import i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e H i s t o r y ;

import i t . uniroma2 . norge . model . jpa . Evidence ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . De l i v e rab l eF i e l dFac to ry ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . De l i v e r ab l eH i s t o ryF i e l dFac to ry ;

import i t . uniroma2 . norge . web . support . EvidenceMapBean ;

import i t . uniroma2 . norge . web . support . StringBean ;

import java . t ex t . SimpleDateFormat ;

import java . u t i l . ArrayList ;

20 import java . u t i l . Arrays ;

import java . u t i l . Date ;

import java . u t i l . HashMap ;

import java . u t i l . L i s t ;

import com . vaadin . data . Item ;

import com . vaadin . data . Property ;

import com . vaadin . data . u t i l . BeanItem ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . t e rmina l . S i z e a b l e ;

30 import com . vaadin . u i . Alignment ;

import com . vaadin . u i . Button ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . Form ;

import com . vaadin . u i . FormFieldFactory ;

import com . vaadin . u i . GridLayout ;

387

Page 406: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import com . vaadin . u i . Hor izonta lLayout ;

import com . vaadin . u i . Label ;

import com . vaadin . u i . Nat i v eSe l e c t ;

40 import com . vaadin . u i . Panel ;

import com . vaadin . u i . RichTextArea ;

import com . vaadin . u i . Table ;

import com . vaadin . u i . Vert i ca lLayout ;

import com . vaadin . u i . Window ;

import com . vaadin . u i . Button . Cl ickEvent ;

import com . vaadin . u i . Button . C l i c k L i s t e n e r ;

import com . vaadin . u i . Window . N o t i f i c a t i o n ;

public class De l ive rab l e sUI {50

private TesiwebAppl icat ion a p p l i c a t i o n ;

private D e l i v e r a b l e C t r l c t r l D e l i v e r a b l e s ;

private Vert i ca lLayout body ;

private GridLayout de l i v e rab l eGr idL ;

private BeanItemContainer<Del ive rab l e> de l ivDataSource ;

60public Table de l i v e rTab l e ;

public Nat iveSe l e c t p r o j e c t L i s t ;

private Window d e l i v e r a b l e D e t a i l ;

private Window del iverab leMapping ;

private Window del iverableSetComment ;

70public De l ive rab l e sUI ( Tes iwebAppl icat ion appl ) {

this . a p p l i c a t i o n = appl ;

c t r l D e l i v e r a b l e s = a p p l i c a t i o n . g e t C t r l D e l i v e r a b l e s ( ) ;

body = a p p l i c a t i o n . getBody ( ) ;

}

public void p r o j e c t s L i s t ( ) {a p p l i c a t i o n . u r i f u . setFragment ( ” d e l i v e r a b l e s / p r o j e c t s L i s t ” ) ;

c t r l D e l i v e r a b l e s = a p p l i c a t i o n . g e t C t r l D e l i v e r a b l e s ( ) ;

80 LoggedUser user = ( LoggedUser ) a p p l i c a t i o n . getUser ( ) ;

a p p l i c a t i o n . setArea ( ”” ) ;

body . removeAllComponents ( ) ;

Panel p = new Panel ( ”Agreements” ) ;

p . s e tS i z eUnde f ined ( ) ;

de l i v e rab l eGr idL = new GridLayout (3 , 2) ;

de l i v e rab l eGr idL . se tSpac ing ( true ) ;

d e l i v e rab l eGr idL . setMargin ( true ) ;

d e l i v e rab l eGr idL . s e t S i z e F u l l ( ) ;

d e l i v e rab l eGr idL . addComponent (p , 0 , 0) ;

90 body . addComponent ( de l i v e rab l eGr idL ) ;

body . setComponentAlignment ( de l ive rab l eGr idL , Alignment .TOP LEFT) ;

388

Page 407: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

p r o j e c t L i s t = new Nat iveSe l e c t ( ” Please s e l e c t an agreement ” ) ;

BeanItemContainer<Agreement> ds = new BeanItemContainer<Agreement>(user

. p ro j e c t sForRo l e ( null ) ) ;

p r o j e c t L i s t . setContainerDataSource ( ds ) ;

p r o j e c t L i s t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

p r o j e c t L i s t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

100 p r o j e c t L i s t . setValue ( ”” ) ;

p r o j e c t L i s t . setImmediate ( true ) ;

p r o j e c t L i s t . addLis tener ( c t r l D e l i v e r a b l e s . g e t P r o j e c t S e l e c t e d ( ) ) ;

p . addComponent ( p r o j e c t L i s t ) ;

}

public void d e l i v e r a b l e s L i s t ( f ina l boolean readOnly ) {c t r l D e l i v e r a b l e s = a p p l i c a t i o n . g e t C t r l D e l i v e r a b l e s ( ) ;

Panel p = new Panel ( ” D e l i v e r a b l e s ” ) ;

110 p . s e t S i z e F u l l ( ) ;

d e l i v e rab l eGr idL . removeComponent (0 , 1) ;

de l i v e rab l eGr idL . addComponent (p , 0 , 1 , 2 , 1) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( d e l i v e r a b l e D e t a i l ) ;

Panel s i l = new Panel ( ” D e l i v e r a b l e s s e t agreed ” ) ;

s i l . s e t S i z e F u l l ( ) ;

d e l i v e rab l eGr idL . removeComponent (2 , 0) ;

de l i v e rab l eGr idL . addComponent ( s i l , 2 , 0) ;

de l i v e rab l eGr idL . setComponentAlignment ( s i l , Alignment .TOP CENTER) ;

120St r ing tmp = c t r l D e l i v e r a b l e s . a c tua lDe l i ve rab l eApprova lS ta tus ( ) ;

i f (tmp == null )

tmp = ” D e l i v e r a b l e s s e t proposed ” ;

else

tmp = ” D e l i v e r a b l e s s e t i s ” + tmp ;

s i l . addComponent (new Label (tmp) ) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

i f ( ! readOnly ) {Button btnAccept = new Button ( ”Accept a l l d e l i v e r a b l e s ” ,

130 new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

c t r l D e l i v e r a b l e s

. applyActionDelSet ( De l ivAct ions .ACCEPT) ;

}}) ;

Button btnReject = new Button ( ” Reject a l l d e l i v e r a b l e s ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

c t r l D e l i v e r a b l e s

140 . applyActionDelSet ( De l ivAct ions .REJECT) ;

}}) ;

for ( De l ivAct ions a : c t r l D e l i v e r a b l e s . getAdmittedAct ionsDel ivSet ( ) ) {switch ( a ) {case ACCEPT:

btnLayout . addComponent ( btnAccept ) ;

break ;

case REJECT:

389

Page 408: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

btnLayout . addComponent ( btnReject ) ;

150 break ;

}}btnLayout

. addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

}Button btnComment = new Button ( ”Comment” , new Button . C l i c k L i s t e n e r ( ) {

public void buttonCl ick ( ClickEvent event ) {showDeliverablesComment ( readOnly ) ;

}160 }) ;

btnLayout . addComponent (btnComment) ;

s i l . addComponent ( btnLayout ) ;

Panel map = new Panel ( ” Evidences mapping” ) ;

map . s e t S i z e F u l l ( ) ;

d e l i v e rab l eGr idL . removeComponent (1 , 0) ;

de l i v e rab l eGr idL . addComponent (map, 1 , 0) ;

de l i v e rab l eGr idL . setComponentAlignment (map, Alignment .TOP CENTER) ;

170 Button btnMapping = new Button ( ”Mapping” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

mappingGrid ( ) ;

}}) ;

map . addComponent ( btnMapping ) ;

d e l i v e rTab l e = new Table ( ) {@Override

protected St r ing formatPropertyValue ( Object rowId , Object co l Id ,

180 Property property ) {Object v = property . getValue ( ) ;

i f ( v instanceof Date ) {Date dateValue = ( Date ) v ;

SimpleDateFormat df = new SimpleDateFormat (

”d MMM yyyy HH:mm: s s ” ) ;

return df . format ( dateValue ) ;

}return super . formatPropertyValue ( rowId , co l Id , property ) ;

}190 } ;

d e l i v e rTab l e . s e t S e l e c t a b l e ( fa l se ) ;

d e l i v e rTab l e . setImmediate ( fa l se ) ;

L i s t<Del ive rab l e> datas = c t r l D e l i v e r a b l e s . g e t D e l i v e r a b l e s L i s t ( ) ;

i f ( datas . s i z e ( ) > 0) {de l ivDataSource = new BeanItemContainer<Del ive rab l e >(datas ) ;

d e l i v e rTab l e . setContainerDataSource ( de l ivDataSource ) ;

d e l i v e rTab l e . se tVis ib leColumns (new Object [ ] { ” de l ivCateg ” ,

” de l ivSubcateg ” , ”name” , ”mappedItemsNum” }) ;

d e l i v e rTab l e . setColumnHeaders (new St r ing [ ] { ” Category ” ,

200 ” Subcategory ” , ”Name” , ” Evidences ” }) ;

d e l i v e rTab l e . set ItemCapt ionPropertyId ( ” d e l i v e r a b l e I d ” ) ;

d e l i v e rTab l e . setColumnReorderingAllowed ( fa l se ) ;

d e l i v e rTab l e . setColumnCollapsingAllowed ( fa l se ) ;

int x = 20 ;

390

Page 409: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

i f ( datas . s i z e ( ) < x )

x = datas . s i z e ( ) ;

d e l i v e rTab l e . setPageLength ( x ) ;

d e l i v e rTab l e . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

d e l i v e rTab l e . s e t M u l t i S e l e c t ( fa l se ) ;

210 de l i v e rTab l e . addGeneratedColumn ( ”Modify” ,

new Table . ColumnGenerator ( ) {public Component g e n e r a t e Ce l l ( Table source ,

Object itemId , Object columnId ) {Item item = de l i v e rTab l e . getItem ( itemId ) ;

f ina l I n t e g e r qid = ( I n t e g e r ) item . getItemProperty (

” d e l i v e r a b l e I d ” ) . getValue ( ) ;

Button b = new Button ( ”Modify” ) ;

b . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

220 public void buttonCl ick ( ClickEvent event ) {r e f r e shTab l e ( ) ;

c t r l D e l i v e r a b l e s

. d e l i v e r a b l e S e l e c t e d D e t a i l s ( q id ) ;

}}) ;

return b ;

}}) ;

d e l i v e rTab l e . s e t Ce l l S t y l e G e ne r a t o r (new Table . Ce l lS ty l eGenera to r ( ) {230 public St r ing g e t S t y l e ( Object itemId , Object propertyId ) {

i f ( propertyId == null ) {return null ;

} else i f ( propertyId . equa l s ( ”mappedItemsNum” ) ) {Item item = de l i v e rTab l e . getItem ( itemId ) ;

f ina l I n t e g e r num = ( I n t e g e r ) item . getItemProperty (

”mappedItemsNum” ) . getValue ( ) ;

i f (num != null && num > 0)

return ” green ” ;

return ” red ” ;

240 } else {return null ;

}

}}) ;

d e l i v e rTab l e . s e t S i z e F u l l ( ) ;

p . addComponent ( de l i v e rTab l e ) ;

p . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

} else {250 p

. getWindow ( )

. showNot i f i c a t i on (

” Not ice ” ,

”<br/>There aren ’ t any d e l i v e r a b l e f o r t h i s agreement . ”

+ ”<br/><br/>You can add a new document by c l i c k i n g the button . ” ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}Horizonta lLayout bot ton i = new Horizonta lLayout ( ) ;

Button c r e a t e = new Button ( ”Add d e l i v e r a b l e ” ) ;

260 c r e a t e . addLis tener (new C l i c k L i s t e n e r ( ) {

391

Page 410: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Override

public void buttonCl ick ( ClickEvent event ) {addDe l ive rab l e ( ) ;

}}) ;

bot ton i . addComponent ( c r e a t e ) ;

p . addComponent ( bot ton i ) ;

d e l i v e rab l eGr idL . r eques tRepa intAl l ( ) ;

}270

private void r e f r e shTab l e ( ) {i f ( de l ivDataSource != null && del ivDataSource . get I temIds ( ) != null ) {

for ( D e l i v e r a b l e d : de l ivDataSource . get I temIds ( ) ) {c t r l D e l i v e r a b l e s . r e f r e s h ( de l ivDataSource . getItem (d) . getBean ( ) ) ;

}Object [ ] v i s ib leColumns = de l i v e rTab l e . getVis ib leColumns ( ) ;

d e l i v e rTab l e . setContainerDataSource ( de l ivDataSource ) ;

d e l i v e rTab l e . se tVis ib leColumns ( v i s ib leColumns ) ;

d e l i v e rTab l e . r eques tRepa intAl l ( ) ;

280 de l i v e rab l eGr idL . r eques tRepa intAl l ( ) ;

}}

protected void addDe l ive rab l e ( ) {c t r l D e l i v e r a b l e s = a p p l i c a t i o n . g e t C t r l D e l i v e r a b l e s ( ) ;

DelivCategManager categMngr = new DelivCategManager ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( d e l i v e r a b l e D e t a i l ) ;

d e l i v e r a b l e D e t a i l = new Window( ”New d e l i v e r a b l e ” ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) d e l i v e r a b l e D e t a i l . getContent ( ) ;

290 p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

f ina l D e l i v e r a b l e d = new D e l i v e r a b l e ( ) ;

d . setName ( ”” ) ;

BeanItem<Del ive rab l e> delItem = new BeanItem<Del ive rab l e >(d) ;

f ina l Form addingForm = new Form ( ) ;

addingForm . setWriteThrough ( fa l se ) ;

300 addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new De l i v e rab l eF i e l dFac to ry (d , categMngr

. viewAllCateg ( ) ) ) ;

addingForm . setItemDataSource ( de l Item ) ;

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”name” , ” d e s c r i p t i o n ” , ” de l ivCateg ” , ” de l ivSubcateg ” ,

” type ” , ” subtype1 ” , ” subtype2 ” }) ) ;

Button apply = new Button ( ”Add” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {310 addingForm . commit ( ) ;

c t r l D e l i v e r a b l e s . c r e a t e D e l i v e r a b l e (d) ;

} catch ( SaveException e ) {e . pr intStackTrace ( ) ;

}}

}) ;

392

Page 411: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

p . addComponent ( addingForm ) ;

p . addComponent ( apply ) ;

d e l i v e r a b l e D e t a i l . c en t e r ( ) ;

320 a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( d e l i v e r a b l e D e t a i l ) ;

}

public void d e l i v e r a b l e D e t a i l s ( f ina l boolean onlyHistory ,

f ina l boolean modify ) {c t r l D e l i v e r a b l e s = a p p l i c a t i o n . g e t C t r l D e l i v e r a b l e s ( ) ;

DelivCategManager categMngr = new DelivCategManager ( ) ;

f ina l D e l i v e r a b l e d e l i = c t r l D e l i v e r a b l e s . g e t R e f e r e n c e D e l i v e r a b l e ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( d e l i v e r a b l e D e t a i l ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( de l iverab leMapping ) ;

330 St r ing t i t l e = ” D e l i v e r a b l e Id : ” + d e l i . g e t D e l i v e r a b l e I d ( ) ;

t i t l e = ” D e l i v e r a b l e d e t a i l s ” ;

i f ( on lyHi s tory )

t i t l e = ” History ” ;

d e l i v e r a b l e D e t a i l = new Window( t i t l e ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) d e l i v e r a b l e D e t a i l . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

340 i f ( ! on lyHi s tory ) {

BeanItem<Del ive rab l e> delItem = new BeanItem<Del ive rab l e >( d e l i ) ;

f ina l Form addingForm = new Form ( ) ;

addingForm . setWriteThrough ( fa l se ) ;

addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new De l i v e rab l eF i e l dFac to ry ( d e l i ,

categMngr . viewAllCateg ( ) ) ) ;

addingForm . setItemDataSource ( de l Item ) ;

350 addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”name” , ” d e s c r i p t i o n ” , ” de l ivCateg ” , ” de l ivSubcateg ” ,

” type ” , ” subtype1 ” , ” subtype2 ” }) ) ;

Button save = new Button ( ”Save and c l o s e ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

addingForm . commit ( ) ;

c t r l D e l i v e r a b l e s . s a v e D e l i v e r a b l e s ( d e l i ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

360 d e l i v e r a b l e D e t a i l ) ;

}}) ;

Button c l o s e = new Button ( ” Close without sav ing ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

d e l i v e r a b l e D e t a i l ) ;

}370 }) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( save ) ;

393

Page 412: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

btnLayout . addComponent (new Label ( ” ” ,

Label .CONTENT PREFORMATTED) ) ;

btnLayout . addComponent ( c l o s e ) ;

p . addComponent ( addingForm ) ;

p . setComponentAlignment ( addingForm , ” cente r bottom” ) ;

p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

380 }

List<Del iverab leEvidence> des = d e l i . g e t Inc ludedDe l i v e rab l eEv idence s ( ) ;

i f ( des != null && des . s i z e ( ) > 0) {f ina l HashMap<Del iverab leEvidence , EvidenceMapBean> f i l l i n g s = new

HashMap<Del iverab leEvidence , EvidenceMapBean>() ;

ArrayList<EvidenceMapBean> datas = new ArrayList<EvidenceMapBean>() ;

for ( De l ive rab l eEv idence de : des ) {Evidence answsetans = de . getAnswsetAnsw ( ) ;

i f ( answsetans . getResponse ( ) . equa l s IgnoreCase ( ” yes ” ) ) {EvidenceMapBean f = new EvidenceMapBean ( de ) ;

390 f i l l i n g s . put ( f . getDelEvid ( ) , f ) ;

datas . add ( f ) ;

}}p . addComponent (new Label ( ” Evidences mapped in t h i s d e l i v e r a b l e ” ) ) ;

f ina l Table t = new Table ( ) ;

BeanItemContainer<EvidenceMapBean> ds = new

BeanItemContainer<EvidenceMapBean>(

datas ) ;

t . setContainerDataSource ( ds ) ;

t . se tVis ib leColumns (new Object [ ] { ” ev idence ” , ”comment” ,

400 ” addInfo ” , ” agreementStatus ” }) ;

t . setColumnHeaders (new St r ing [ ] { ” Evidence ” , ”Comment” ,

”Add . In f o . ” , ”Agreed” }) ;

t . setColumnReorderingAllowed ( fa l se ) ;

t . setColumnCollapsingAllowed ( fa l se ) ;

int x = datas . s i z e ( ) ;

x = x > 6 ? 6 : x ;

t . setPageLength ( x ) ;

t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

t . s e t M u l t i S e l e c t ( fa l se ) ;

410p . addComponent ( t ) ;

}

d e l i v e r a b l e D e t a i l . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( d e l i v e r a b l e D e t a i l ) ;

}

protected void showConfirmationComment ( ) {c t r l D e l i v e r a b l e s = a p p l i c a t i o n . g e t C t r l D e l i v e r a b l e s ( ) ;

420 f ina l D e l i v e r a b l e doc = c t r l D e l i v e r a b l e s . g e t R e f e r e n c e D e l i v e r a b l e ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( d e l i v e r a b l e D e t a i l ) ;

d e l i v e r a b l e D e t a i l = new Window( ”Document Id : ” + doc . g e t D e l i v e r a b l e I d ( ) ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) d e l i v e r a b l e D e t a i l . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

394

Page 413: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

f ina l D e l i v e r a b l e H i s t o r y h i s t = new D e l i v e r a b l e H i s t o r y ( ) ;

h i s t . setComment ( ”” ) ;

430 BeanItem<De l i v e rab l eH i s to ry> a l t I t em = new BeanItem<De l iv e rab l eH i s to ry >(

h i s t ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm

. setFormFieldFactory (new De l i v e rab l eH i s t o ryF i e l dFac to ry ( h i s t ) ) ;

modifyForm . setItemDataSource ( a l t I t em ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays

. a s L i s t (new St r ing [ ] { ”comment” }) ) ;

440p . addComponent (new Label ( ” Please exp la in the reason o f t h i s ac t i on ” ) ) ;

p . addComponent ( modifyForm ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

modifyForm . commit ( ) ;

c t r l D e l i v e r a b l e s . saveDer ivab l eH i s to ry ( h i s t ) ;

}}) ;

450 Button c l o s e = new Button ( ” Discard ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

d e l i v e r a b l e D e t a i l ) ;

}}) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

460 btnLayout . addComponent ( c l o s e ) ;

p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

d e l i v e r a b l e D e t a i l . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( d e l i v e r a b l e D e t a i l ) ;

}

public void showDeliverablesComment (boolean readOnly ) {470 c t r l D e l i v e r a b l e s = a p p l i c a t i o n . g e t C t r l D e l i v e r a b l e s ( ) ;

f ina l St r ing doc = c t r l D e l i v e r a b l e s . g e tRe f e r encePro j e c t ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( d e l i v e r a b l e D e t a i l ) ;

a p p l i c a t i o n . getSubWindowManager ( )

. removeSubWindow ( del iverableSetComment ) ;

del iverableSetComment = new Window( ” D e l i v e r a b l e s s e t comment” ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) del iverableSetComment . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

480 del iverableSetComment . setModal ( true ) ;

i f ( ! readOnly ) {

395

Page 414: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

StringBean s t r = new StringBean ( ) ;

s t r . s e t S t r i n g ( doc ) ;

BeanItem<StringBean> a l t I t em = new BeanItem<StringBean >( s t r ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm . setFormFieldFactory (new FormFieldFactory ( ) {490 @Override

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId ,

Component uiContext ) {RichTextArea t f = new RichTextArea ( ) ;

t f . setCapt ion ( ”” ) ;

t f . setWidth (12 , S i z e a b l e .UNITS EM) ;

t f . setValue ( doc == null ? ”” : doc ) ;

return t f ;

}}) ;

500 modifyForm . setItemDataSource ( a l t I t em ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays

. a s L i s t (new St r ing [ ] { ” s t r i n g ” }) ) ;

p . addComponent ( modifyForm ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

modifyForm . commit ( ) ;

c t r l D e l i v e r a b l e s . saveDerivablesSetComment ( doc ) ;

510 }}) ;

Button c l o s e = new Button ( ” Close ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

del iverableSetComment ) ;

}}) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

520 btnLayout . addComponent ( apply ) ;

btnLayout

. addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

btnLayout . addComponent ( c l o s e ) ;

p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

} else {p . addComponent (new Label ( ”The c e r t i f i e r comment : ” ) ) ;

p . addComponent (new Label ( doc , Label .CONTENT XHTML) ) ;

}530 del iverableSetComment . c en te r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( del iverableSetComment ) ;

}

protected void showConfirmationComment ( f ina l Del ivAct ions act ) {c t r l D e l i v e r a b l e s = a p p l i c a t i o n . g e t C t r l D e l i v e r a b l e s ( ) ;

f ina l D e l i v e r a b l e doc = c t r l D e l i v e r a b l e s . g e t R e f e r e n c e D e l i v e r a b l e ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( d e l i v e r a b l e D e t a i l ) ;

d e l i v e r a b l e D e t a i l = new Window( ”Document Id : ” + doc . g e t D e l i v e r a b l e I d ( ) ) ;

396

Page 415: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

Vert i ca lLayout p = ( Vert i ca lLayout ) d e l i v e r a b l e D e t a i l . getContent ( ) ;

540 p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

f ina l D e l i v e r a b l e H i s t o r y h i s t = new D e l i v e r a b l e H i s t o r y ( ) ;

h i s t . setComment ( ”” ) ;

BeanItem<De l i v e rab l eH i s to ry> a l t I t em = new BeanItem<De l iv e rab l eH i s to ry >(

h i s t ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

550 modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm

. setFormFieldFactory (new De l i v e rab l eH i s t o ryF i e l dFac to ry ( h i s t ) ) ;

modifyForm . setItemDataSource ( a l t I t em ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays

. a s L i s t (new St r ing [ ] { ”comment” }) ) ;

p . addComponent (new Label ( ” Please exp la in the reason o f t h i s ac t i on ” ) ) ;

p . addComponent ( modifyForm ) ;

560 Button apply = new Button ( ”Confirm” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

modifyForm . commit ( ) ;

try {c t r l D e l i v e r a b l e s . applyAction ( act , h i s t ) ;

} catch ( SaveException e ) {e . pr intStackTrace ( ) ;

}}

}) ;

570 Button c l o s e = new Button ( ” Cancel ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

d e l i v e r a b l e D e t a i l ) ;

}}) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

580 btnLayout . addComponent ( c l o s e ) ;

p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

d e l i v e r a b l e D e t a i l . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( d e l i v e r a b l e D e t a i l ) ;

}

public void d e l i v e r a b l e D e t a i l s H i s t o r y ( ) {590 d e l i v e r a b l e D e t a i l s ( true , fa l se ) ;

}

public void de l iverab leMapping (boolean readOnly ) {c t r l D e l i v e r a b l e s = a p p l i c a t i o n . g e t C t r l D e l i v e r a b l e s ( ) ;

397

Page 416: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

f ina l D e l i v e r a b l e d e l i = c t r l D e l i v e r a b l e s . g e t R e f e r e n c e D e l i v e r a b l e ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( d e l i v e r a b l e D e t a i l ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( de l iverab leMapping ) ;

S t r ing t i t l e = ” D e l i v e r a b l e Id : ” + d e l i . g e t D e l i v e r a b l e I d ( ) ;

t i t l e = ” Evidence to d e l i v e r a b l e mapping” ;

600 de l iverab leMapping = new Window( t i t l e ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) de l iverab leMapping . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

L i s t<Del iverab leEvidence> des = d e l i . g e t Inc ludedDe l i v e rab l eEv idence s ( ) ;

i f ( des != null && des . s i z e ( ) > 0) {f ina l HashMap<Del iverab leEvidence , EvidenceMapBean> f i l l i n g s = new

HashMap<Del iverab leEvidence , EvidenceMapBean>() ;

ArrayList<EvidenceMapBean> datas = new ArrayList<EvidenceMapBean>() ;

610 for ( De l ive rab l eEv idence de : des ) {Evidence answsetans = de . getAnswsetAnsw ( ) ;

i f ( answsetans . getResponse ( ) . equa l s IgnoreCase ( ” yes ” ) ) {EvidenceMapBean f = new EvidenceMapBean ( de ) ;

f i l l i n g s . put ( f . getDelEvid ( ) , f ) ;

datas . add ( f ) ;

}}p . addComponent (new Label ( d e l i . getName ( ) ) ) ;

f ina l Table t = new Table ( ) ;

620 BeanItemContainer<EvidenceMapBean> ds = new

BeanItemContainer<EvidenceMapBean>(

datas ) ;

t . setContainerDataSource ( ds ) ;

t . se tVis ib leColumns (new Object [ ] { ” ev idence ” , ”commentField” }) ;

t . setColumnHeaders (new St r ing [ ] { ” Evidence ” , ”Comment” }) ;

t . setColumnReorderingAllowed ( fa l se ) ;

t . setColumnCollapsingAllowed ( fa l se ) ;

int x = datas . s i z e ( ) ;

x = x > 10 ? 10 : x ;

t . setPageLength ( x ) ;

630 t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

t . s e t M u l t i S e l e c t ( fa l se ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

ArrayList<Del iverab leEvidence> dats = new

ArrayList<Del iverab leEvidence >() ;

for ( De l ive rab l eEv idence de : f i l l i n g s . keySet ( ) ) {EvidenceMapBean d = f i l l i n g s . get ( de ) ;

de . setApprovationComment ( ( S t r ing ) d . getCommentField ( )

. getValue ( ) ) ;

640 dats . add ( de ) ;

}c t r l D e l i v e r a b l e s . saveDel iverablesComments ( dats ) ;

}}) ;

Button d i s ca rd = new Button ( ” Discard ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

de l iverab leMapping ( fa l se ) ;

398

Page 417: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}}) ;

650 Button c l o s e = new Button ( ” Close ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

de l iverab leMapping ) ;

}}) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

i f ( readOnly ) {btnLayout . addComponent ( apply ) ;

btnLayout . addComponent ( d i s ca rd ) ;

660 btnLayout . addComponent (new Label ( ” ” ,

Label .CONTENT PREFORMATTED) ) ;

}btnLayout . addComponent ( c l o s e ) ;

p . addComponent ( t ) ;

p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

}de l iverab leMapping . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( de l iverab leMapping ) ;

670 }

public void mappingGrid ( ) {c t r l D e l i v e r a b l e s = a p p l i c a t i o n . g e t C t r l D e l i v e r a b l e s ( ) ;

L i s t<Del ive rab l e> d e l i v s = c t r l D e l i v e r a b l e s . g e t D e l i v e r a b l e s L i s t ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( de l iverab leMapping ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( d e l i v e r a b l e D e t a i l ) ;

a p p l i c a t i o n . getSubWindowManager ( )

. removeSubWindow ( del iverableSetComment ) ;

de l iverab leMapping = new Window( ”Matrix o f ev idence s and d e l i v e r a b l e s ” ) ;

680 Vert i ca lLayout p = ( Vert i ca lLayout ) de l iverab leMapping . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e t S i z e F u l l ( ) ;

de l iverab leMapping . setModal ( true ) ;

f ina l Table del iverTableMapping = new Table ( ) ;

del iverTableMapping . s e t S e l e c t a b l e ( true ) ;

690 del iverTableMapping . setImmediate ( true ) ;

L i s t<Evidence> datas = c t r l D e l i v e r a b l e s . g e tEv idence sL i s t ( ) ;

i f ( datas . s i z e ( ) > 0) {del iverTableMapping . addContainerProperty ( ” Evidence ” , S t r ing . class ,

null ) ;

for ( D e l i v e r a b l e d : d e l i v s ) {del iverTableMapping . addContainerProperty (d . getName ( ) ,

S t r ing . class , null ) ;

}del iverTableMapping . addContainerProperty ( ”Num. Del iv ” ,

700 I n t e g e r . class , null ) ;

f ina l int totColumn = 2 + d e l i v s . s i z e ( ) ;

int [ ] totEvid = new int [ totColumn ] ;

Object [ ] [ ] i tems = new Object [ datas . s i z e ( ) ] [ totColumn ] ;

399

Page 418: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

f ina l HashMap<Object , Object []> i t emIds = new HashMap<Object , Object [ ] > ( ) ;

int j = 0 ;

for ( Evidence aa : datas ) {i tems [ j ] [ 0 ] = aa . getAlternat iveAnswer ( ) . getAnswer ( ) ;

int to t = 0 ;

int i = 1 ;

710 for ( D e l i v e r a b l e d : d e l i v s ) {Del ive rab l eEv idence de = c t r l D e l i v e r a b l e s

. g e tDe l i v e rab l eEv idence (d , aa ) ;

i f ( de != null ) {i f ( de . ge t Inc luded ( ) ) {

i tems [ j ] [ i ] = ” yes ” ;

totEvid [ i ]++;

to t++;

} else

i tems [ j ] [ i ] = ”no” ;

720 } else {i tems [ j ] [ i ] = ”” ;

}i ++;

}i tems [ j ] [ totColumn − 1 ] = new I n t e g e r ( to t ) ;

Object id = del iverTableMapping . addItem ( items [ j ] ,

new I n t e g e r ( j ) ) ;

i temIds . put ( id , i tems [ j ] ) ;

j ++;

730 }del iverTableMapping . s e t F o o t e r V i s i b l e ( true ) ;

del iverTableMapping . setColumnFooter (0 , ” Evidences per document” ) ;

f ina l HashMap<Str ing , Integer> totEvidMap = new HashMap<Str ing , Integer >() ;

for ( int i = 1 ; i < 1 + d e l i v s . s i z e ( ) ; i++) {St r ing k = d e l i v s . get ( i − 1) . getName ( ) ;

I n t e g e r v = new I n t e g e r ( totEvid [ i ] ) ;

del iverTableMapping . setColumnFooter (k , ”” + v ) ;

totEvidMap . put (k , v ) ;

}740 del iverTableMapping . setColumnFooter ( ” Evidence ” ,

”Number o f l i nked ev idence ” ) ;

del iverTableMapping

. s e t C e l l S ty l e Ge n e r a t o r (new Table . Ce l lS ty l eGenera to r ( ) {public St r ing g e t S t y l e ( Object itemId , Object propertyId ) {

Item item = del iverTableMapping . getItem ( itemId ) ;

i f ( propertyId == null | | item == null

| | propertyId . equa l s ( ”Num. Del iv ” ) )

return null ;

750 I n t e g e r num;

i f ( totEvidMap . containsKey ( propertyId ) ) {num = totEvidMap . get ( propertyId ) ;

i f (num == null | | num == 0)

return ” ye l low ” ;

}num = ( I n t e g e r ) item . getItemProperty ( ”Num. Del iv ” )

. getValue ( ) ;

i f (num != null && num == 0)

return ” orange ” ;

400

Page 419: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

760 return null ;

}}) ;

del iverTableMapping . setColumnReorderingAllowed ( true ) ;

del iverTableMapping . setColumnCollapsingAllowed ( true ) ;

int x = 15 ;

del iverTableMapping . setPageLength ( x ) ;

del iverTableMapping . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

del iverTableMapping . s e t M u l t i S e l e c t ( fa l se ) ;

del iverTableMapping . s e t S i z e F u l l ( ) ;

770 p . addComponent ( del iverTableMapping ) ;

p . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

} else {p . addComponent (new Label ( ”No datas ” ) ) ;

}

de l iverab leMapping . c en t e r ( ) ;

de l iverab leMapping . setWidth (70 , S i z e a b l e .UNITS EM) ;

de l iverab leMapping . s e tHe ight (55 , S i z e a b l e .UNITS EM) ;

del iverTableMapping . s e t S i z e F u l l ( ) ;

780 a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( de l iverab leMapping ) ;

}

}

D.6.5 Classe DocumentsUI.java

package i t . uniroma2 . norge . web ;

import i t . uniroma2 . norge . c o n t r o l l e r . DocumentCtrl ;

import i t . uniroma2 . norge . c o n t r o l l e r . LoggedUser ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . c o n t r o l l e r . DocumentCtrl . DocActions ;

import i t . uniroma2 . norge . model . jpa . Document ;

import i t . uniroma2 . norge . model . jpa . DocumentHistory ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

10 import i t . uniroma2 . norge . web . f i e l d f a c t o r y . DocumentHistoryFieldFactory ;

import java . t ex t . SimpleDateFormat ;

import java . u t i l . Arrays ;

import java . u t i l . C o l l e c t i o n s ;

import java . u t i l . Comparator ;

import java . u t i l . Date ;

import java . u t i l . L i s t ;

import com . vaadin . data . Item ;

20 import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . data . u t i l . BeanItem ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . u i . Alignment ;

import com . vaadin . u i . Button ;

import com . vaadin . u i . CheckBox ;

import com . vaadin . u i . Component ;

401

Page 420: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import com . vaadin . u i . Form ;

import com . vaadin . u i . GridLayout ;

30 import com . vaadin . u i . Hor izonta lLayout ;

import com . vaadin . u i . Label ;

import com . vaadin . u i . Link ;

import com . vaadin . u i . Nat i v eSe l e c t ;

import com . vaadin . u i . Panel ;

import com . vaadin . u i . Table ;

import com . vaadin . u i . Vert i ca lLayout ;

import com . vaadin . u i . Window ;

import com . vaadin . u i . Button . Cl ickEvent ;

import com . vaadin . u i . Button . C l i c k L i s t e n e r ;

40 import com . vaadin . u i . Window . N o t i f i c a t i o n ;

public class DocumentsUI {

private TesiwebAppl icat ion a p p l i c a t i o n ;

private DocumentCtrl ctrlDocument ;

private Vert i ca lLayout body ;

50 private GridLayout documentGridL ;

private BeanItemContainer<Document> documentDataSource ;

public Table documentTable ;

public Nat iveSe l e c t l ;

private Window documDetail ;

60 public DocumentsUI ( Tes iwebAppl icat ion appl ) {this . a p p l i c a t i o n = appl ;

ctrlDocument = a p p l i c a t i o n . getCtrlDocument ( ) ;

body = a p p l i c a t i o n . getBody ( ) ;

}

public void p r o j e c t s L i s t ( ) {ctrlDocument = a p p l i c a t i o n . getCtrlDocument ( ) ;

LoggedUser user = ( LoggedUser ) a p p l i c a t i o n . getUser ( ) ;

a p p l i c a t i o n . setArea ( ”” ) ;

70 body . removeAllComponents ( ) ;

Panel p = new Panel ( ”Agreements” ) ;

p . s e tS i z eUnde f ined ( ) ;

documentGridL = new GridLayout (2 , 3) ;

documentGridL . se tSpac ing ( true ) ;

documentGridL . setMargin ( true ) ;

documentGridL . s e t S i z e F u l l ( ) ;

documentGridL . addComponent (p , 0 , 0) ;

body . addComponent ( documentGridL ) ;

body . setComponentAlignment ( documentGridL , Alignment .TOP LEFT) ;

80l = new Nat iveSe l e c t ( ” Please s e l e c t an agreement ” ) ;

BeanItemContainer<Agreement> ds = new BeanItemContainer<Agreement>(user

. p ro j e c t sForRo l e ( null ) ) ;

402

Page 421: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

l . setContainerDataSource ( ds ) ;

l . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

l . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

l . setValue ( ”” ) ;

l . setImmediate ( true ) ;

90 l . addLis tener ( ctrlDocument ) ;

p . addComponent ( l ) ;

}

public void documentsList ( ) {ctrlDocument = a p p l i c a t i o n . getCtrlDocument ( ) ;

Panel p = new Panel ( ”Documents” ) ;

p . s e tS i z eUnde f ined ( ) ;

documentGridL . removeComponent (0 , 1) ;

100 documentGridL . addComponent (p , 0 , 1) ;

documentTable = new Table ( ) {@Override

protected St r ing formatPropertyValue ( Object rowId , Object co l Id ,

Property property ) {Object v = property . getValue ( ) ;

i f ( v instanceof Date ) {Date dateValue = ( Date ) v ;

SimpleDateFormat df = new SimpleDateFormat (

110 ”d MMM yyyy HH:mm: s s ” ) ;

return df . format ( dateValue ) ;

}return super . formatPropertyValue ( rowId , co l Id , property ) ;

}} ;

documentTable . s e t S e l e c t a b l e ( fa l se ) ;

documentTable . setImmediate ( fa l se ) ;

L i s t<Document> datas = ctrlDocument . getDocumentsList ( ) ;

i f ( datas . s i z e ( ) > 0) {120 C o l l e c t i o n s . s o r t ( datas , new Comparator<Document>() {

@Override

public int compare ( Document o1 , Document o2 ) {i f ( o1 . getPdfCreat ionDate ( ) . a f t e r ( o2 . getPdfCreat ionDate ( ) ) )

return −1;

else i f ( o1 . getPdfCreat ionDate ( ) . b e f o r e (

o2 . getPdfCreat ionDate ( ) ) )

return 1 ;

return 0 ;

}130 }) ;

documentDataSource = new BeanItemContainer<Document>(datas ) ;

documentTable . setContainerDataSource ( documentDataSource ) ;

documentTable . setVis ib leColumns (new Object [ ] { ” f i l ename ” ,

” s t a t u s ” , ” pdfCreationDate ” , ”modDate” }) ;

documentTable . setColumnHeaders (new St r ing [ ] { ” Filename ” , ” Status ” ,

” Created ” , ” Last ac t i on ” }) ;

documentTable . set ItemCapt ionPropertyId ( ”documentId” ) ;

documentTable . setColumnReorderingAllowed ( fa l se ) ;

documentTable . setColumnCollapsingAllowed ( fa l se ) ;

403

Page 422: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

140 int x = 20 ;

i f ( datas . s i z e ( ) < x )

x = datas . s i z e ( ) ;

documentTable . setPageLength ( x ) ;

documentTable . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

documentTable . s e t M u l t i S e l e c t ( fa l se ) ;

documentTable . addGeneratedColumn ( ” D e t a i l s ” ,

new Table . ColumnGenerator ( ) {public Component g e n e r a t e Ce l l ( Table source ,

Object itemId , Object columnId ) {150 Item item = documentTable . getItem ( itemId ) ;

f ina l I n t e g e r qid = ( I n t e g e r ) item . getItemProperty (

”documentId” ) . getValue ( ) ;

Button b = new Button ( ” D e t a i l s ” ) ;

b . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {ctrlDocument . documentSe lectedHistory ( qid ) ;

}}) ;

160 return b ;

}}) ;

documentTable . addGeneratedColumn ( ”Modify” ,

new Table . ColumnGenerator ( ) {public Component g e n e r a t e Ce l l ( Table source ,

Object itemId , Object columnId ) {Item item = documentTable . getItem ( itemId ) ;

f ina l I n t e g e r qid = ( I n t e g e r ) item . getItemProperty (

”documentId” ) . getValue ( ) ;

170 Button b = new Button ( ” Act ions ” ) ;

b . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {ctrlDocument . documentSe lectedDeta i l s ( qid ) ;

}}) ;

return b ;

}}) ;

180 documentTable . addGeneratedColumn ( ”View” ,

new Table . ColumnGenerator ( ) {public Component g e n e r a t e Ce l l ( Table source ,

Object itemId , Object columnId ) {Item item = documentTable . getItem ( itemId ) ;

f ina l I n t e g e r qid = ( I n t e g e r ) item . getItemProperty (

”documentId” ) . getValue ( ) ;

Link exportPDF = new Link ( ”Export PDF” ,

ctrlDocument . exportPDFtest ( qid ) ) ;

return exportPDF ;

190 }}) ;

p . addComponent ( documentTable ) ;

p . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

} else {p

404

Page 423: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

. getWindow ( )

. showNot i f i c a t i on (

” Not ice ” ,

”<br/>There aren ’ t any document f o r t h i s agreement . ”

200 + ”<br/><br/>You can add a new document by c l i c k i n g the button . ” ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}Horizonta lLayout bot ton i = new Horizonta lLayout ( ) ;

Button c r e a t e = new Button ( ” Propose new document” ) ;

c r e a t e . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {addDocument ( ) ;

}210 }) ;

Button exportPDF = new Button ( ” Preview PDF” ) ;

exportPDF . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {showPreviewCheckboxes ( ) ;

}}) ;

bot ton i . addComponent ( c r e a t e ) ;

bot ton i . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

220 bot ton i . addComponent ( exportPDF ) ;

p . addComponent ( bot ton i ) ;

}

private void showPreviewCheckboxes ( ) {ctrlDocument = a p p l i c a t i o n . getCtrlDocument ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( documDetail ) ;

documDetail = new Window( ”Document preview ” ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) documDetail . getContent ( ) ;

p . setMargin ( true ) ;

230 p . se tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

f ina l CheckBox cb graphs = new CheckBox ( ” Pie char t s ” ) ;

f ina l CheckBox cb agreement = new CheckBox (

” Evidence ” ) ;

f ina l CheckBox cb mapping = new CheckBox ( ” D e l i v e r a b l e s ” ) ;

f ina l CheckBox cb parte2 = new CheckBox ( ”Matrix between ev idence s and

d e l i v e r a b l e s ” ) ;

f ina l CheckBox cb h i s to ryE = new CheckBox ( ” His tory o f ev idence ” ) ;

f ina l CheckBox cb his toryD = new CheckBox ( ” His tory o f d e l i v e r a b l e s ” ) ;

f ina l CheckBox cb context = new CheckBox ( ” D e f i n i t i o n o f context ” ) ;

240 cb graphs . setValue ( true ) ;

cb agreement . setValue ( true ) ;

cb mapping . setValue ( true ) ;

cb par te2 . setValue ( true ) ;

cb h i s to ryE . setValue ( true ) ;

cb h i s toryD . setValue ( true ) ;

cb context . setValue ( true ) ;

cb graphs . setImmediate ( true ) ;

cb agreement . setImmediate ( true ) ;

cb mapping . setImmediate ( true ) ;

250 cb par te2 . setImmediate ( true ) ;

405

Page 424: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

cb h i s to ryE . setImmediate ( true ) ;

cb h i s toryD . setImmediate ( true ) ;

Button apply = new Button ( ”Go to preview ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {boolean graphs = cb graphs . booleanValue ( ) ;

boolean parte1 = true ;

boolean agreement = cb agreement . booleanValue ( ) ;

boolean mapping = cb mapping . booleanValue ( ) ;

260 boolean parte2 = cb parte2 . booleanValue ( ) ;

boolean his toryE = cb h i s to ryE . booleanValue ( ) ;

boolean historyD = cb his toryD . booleanValue ( ) ;

boolean context = cb context . booleanValue ( ) ;

ctrlDocument . previewPDF ( parte1 , agreement , mapping , parte2 ,

graphs , historyE , historyD , context ) ;

} catch ( Exception e ) {e . pr intStackTrace ( ) ;

}}

270 }) ;

p . addComponent (new Label (

” In format ion to in c lude ” ) ) ;

p . addComponent ( cb graphs ) ;

p . addComponent ( cb agreement ) ;

p . addComponent ( cb mapping ) ;

p . addComponent ( cb par te2 ) ;

p . addComponent ( cb h i s to ryE ) ;

p . addComponent ( cb h i s toryD ) ;

p . addComponent ( cb context ) ;

280 p . addComponent ( apply ) ;

documDetail . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( documDetail ) ;

}

protected void addDocument ( ) {ctrlDocument = a p p l i c a t i o n . getCtrlDocument ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( documDetail ) ;

documDetail = new Window( ”New Document” ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) documDetail . getContent ( ) ;

290 p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

f ina l DocumentHistory dh = new DocumentHistory ( ) ;

dh . setComment ( ”” ) ;

BeanItem<DocumentHistory> ansItem = new BeanItem<DocumentHistory>(dh) ;

f ina l Form addingForm = new Form ( ) ;

addingForm . setWriteThrough ( fa l se ) ;

300 addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new DocumentHistoryFieldFactory (dh) ) ;

addingForm . setItemDataSource ( ansItem ) ;

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays

. a s L i s t (new St r ing [ ] { ”comment” }) ) ;

f ina l CheckBox cb parte1 = new CheckBox ( ” Pr int d e t a i l s o f answers ” ) ;

f ina l CheckBox cb graphs = new CheckBox ( ” Pr int graphs ” ) ;

406

Page 425: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

f ina l CheckBox cb agreement = new CheckBox (

” Pr int in fo rmat ion on agreement ” ) ;

f ina l CheckBox cb mapping = new CheckBox ( ” Pr int in fo rmat ion on mapping” ) ;

310 f ina l CheckBox cb parte2 = new CheckBox ( ” Pr int the matrix o f mapping” ) ;

f ina l CheckBox cb h i s to ryE = new CheckBox ( ” His tory o f ev idence ” ) ;

f ina l CheckBox cb his toryD = new CheckBox ( ” His tory o f d e l i v e r a b l e s ” ) ;

f ina l CheckBox cb context = new CheckBox ( ” D e f i n i t i o n o f context ” ) ;

cb par te1 . setValue ( true ) ;

cb graphs . setValue ( true ) ;

cb agreement . setValue ( true ) ;

cb mapping . setValue ( true ) ;

cb par te2 . setValue ( true ) ;

cb h i s to ryE . setValue ( true ) ;

320 cb his toryD . setValue ( true ) ;

cb context . setValue ( true ) ;

cb par te1 . setImmediate ( true ) ;

cb graphs . setImmediate ( true ) ;

cb agreement . setImmediate ( true ) ;

cb mapping . setImmediate ( true ) ;

cb par te2 . setImmediate ( true ) ;

cb par te1 . addLis tener (new Property . ValueChangeListener ( ) {@Override

public void valueChange ( ValueChangeEvent event ) {330 Boolean v = cb parte1 . booleanValue ( ) ;

cb graphs . setEnabled ( v ) ;

cb agreement . setEnabled ( v ) ;

cb mapping . setEnabled ( v ) ;

cb graphs . setValue ( v ) ;

cb agreement . setValue ( v ) ;

cb mapping . setValue ( v ) ;

}}) ;

Button apply = new Button ( ”Add” , new Button . C l i c k L i s t e n e r ( ) {340 public void buttonCl ick ( ClickEvent event ) {

try {addingForm . commit ( ) ;

boolean graphs = cb graphs . booleanValue ( ) ;

boolean parte1 = cb parte1 . booleanValue ( ) ;

boolean agreement = cb agreement . booleanValue ( ) ;

boolean mapping = cb mapping . booleanValue ( ) ;

boolean parte2 = cb parte2 . booleanValue ( ) ;

boolean his toryE = cb h i s to ryE . booleanValue ( ) ;

boolean historyD = cb his toryD . booleanValue ( ) ;

350 boolean context = cb context . booleanValue ( ) ;

ctrlDocument . createDocument (dh , parte1 , agreement , mapping ,

parte2 , graphs , historyE , historyD , context ) ;

} catch ( SaveException e ) {e . pr intStackTrace ( ) ;

}}

}) ;

p . addComponent ( addingForm ) ;

p . addComponent (new Label (

360 ” Spec i f y par t s that have to be inc luded in t h i s preview ” ) ) ;

p . addComponent ( cb par te1 ) ;

p . addComponent ( cb graphs ) ;

407

Page 426: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

p . addComponent ( cb agreement ) ;

p . addComponent ( cb mapping ) ;

p . addComponent ( cb par te2 ) ;

p . addComponent ( apply ) ;

documDetail . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( documDetail ) ;

}370

public void documentDetai ls (boolean on lyHi s tory ) {ctrlDocument = a p p l i c a t i o n . getCtrlDocument ( ) ;

f ina l Document doc = ctrlDocument . getReferenceDocument ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( documDetail ) ;

S t r ing t i t l e = ”Document Id : ” + doc . getDocumentId ( ) ;

t i t l e = ”Document d e t a i l s ” ;

i f ( on lyHi s tory )

t i t l e = ” History ” ;

documDetail = new Window( t i t l e ) ;

380 Vert i ca lLayout p = ( Vert i ca lLayout ) documDetail . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

i f ( ! on lyHi s tory ) {SimpleDateFormat df = new SimpleDateFormat ( ”d MMM yyyy HH:mm: s s ” ) ;

GridLayout g l = new GridLayout (3 , 3) ;

g l . addComponent (new Label ( ” Filename : ” ) , 0 , 0) ;

390 g l . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) , 1 , 0) ;

g l . addComponent (new Label ( doc . getFi lename ( ) ) , 2 , 0) ;

g l . addComponent (new Label ( ” Created : ” ) , 0 , 1) ;

g l . addComponent (new Label ( df . format ( doc . getPdfCreat ionDate ( ) ) ) , 2 ,

1) ;

g l . addComponent (new Label ( ” Status : ” ) , 0 , 2) ;

g l . addComponent (new Label ( doc . ge tStatus ( ) ) , 2 , 2) ;

p . addComponent ( g l ) ;

p . setComponentAlignment ( gl , ” c ent e r ” ) ;

400Button btnAccept = new Button ( ”Accept proposa l ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

showConfirmationComment ( DocActions .ACCEPT) ;

}}) ;

Button btnReject = new Button ( ” Reject proposa l ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

410 showConfirmationComment ( DocActions .REJECT) ;

}}) ;

Button btnPropDelet = new Button ( ” Propose withdrawn” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

showConfirmationComment ( DocActions .PROPOSE DELETION) ;

}}) ;

408

Page 427: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

Button btnDelete = new Button ( ”Accept Withdrawn” ,

420 new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

showConfirmationComment ( DocActions .DELETE) ;

}}) ;

Button btnRejDelete = new Button ( ” Reject Withdrawn” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

showConfirmationComment ( DocActions .REJ DELETE) ;

}430 }) ;

Button c l o s e = new Button ( ” Close ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

documDetail ) ;

}}) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

for ( DocActions a : ctrlDocument . getAdmittedActions ( ) ) {switch ( a ) {

440 case ACCEPT:

btnLayout . addComponent ( btnAccept ) ;

break ;

case REJECT:

btnLayout . addComponent ( btnReject ) ;

break ;

case PROPOSE DELETION:

btnLayout . addComponent ( btnPropDelet ) ;

break ;

case DELETE:

450 btnLayout . addComponent ( btnDelete ) ;

break ;

case REJ DELETE:

btnLayout . addComponent ( btnRejDelete ) ;

break ;

}}btnLayout . addComponent (new Label ( ” ” ,

Label .CONTENT PREFORMATTED) ) ;

btnLayout . addComponent ( c l o s e ) ;

460 p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

}

f ina l List<DocumentHistory> h i s t o r y = doc . getDocumentHistor ies ( ) ;

i f ( h i s t o r y != null && h i s t o r y . s i z e ( ) > 0) {C o l l e c t i o n s . s o r t ( h i s to ry , new Comparator<DocumentHistory >() {

@Override

public int compare ( DocumentHistory o1 , DocumentHistory o2 ) {i f ( o1 . getModtime ( ) . a f t e r ( o2 . getModtime ( ) ) )

470 return 1 ;

else i f ( o1 . getModtime ( ) . b e f o r e ( o2 . getModtime ( ) ) )

return −1;

return 0 ;

}

409

Page 428: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}) ;

p . addComponent (new Label ( ” Status changes h i s t o r y ” ) ) ;

f ina l Table h i s tTab le = new Table ( ) {@Override

protected St r ing formatPropertyValue ( Object rowId ,

480 Object co l Id , Property property ) {Object v = property . getValue ( ) ;

i f ( v instanceof Date ) {Date dateValue = ( Date ) v ;

SimpleDateFormat df = new SimpleDateFormat (

”d MMM yyyy HH:mm: s s ” ) ;

return df . format ( dateValue ) ;

}return super . formatPropertyValue ( rowId , co l Id , property ) ;

}490 } ;

h i s tTab l e . s e t S e l e c t a b l e ( fa l se ) ;

h i s tTab l e . setImmediate ( fa l se ) ;

BeanItemContainer<DocumentHistory> ansDataSource = new

BeanItemContainer<DocumentHistory>(

h i s t o r y ) ;

h i s tTab l e . setContainerDataSource ( ansDataSource ) ;

h i s tTab l e . se tVis ib leColumns (new Object [ ] { ”modtime” , ” user ” ,

” r o l e ” , ” ac t i on ” , ”comment” }) ;

h i s tTab l e . setColumnHeaders (new St r ing [ ] { ”Date” , ”User” , ”Role” ,

” Action ” , ”Comment” }) ;

500 h i s tTab l e . setColumnReorderingAllowed ( fa l se ) ;

h i s tTab l e . setColumnCollapsingAllowed ( fa l se ) ;

int x = ansDataSource . s i z e ( ) > 5 ? 5 : ansDataSource . s i z e ( ) ;

h i s tTab l e . setPageLength ( x ) ;

p . addComponent ( h i s tTab le ) ;

}documDetail . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( documDetail ) ;

}510

protected void showConfirmationComment ( ) {ctrlDocument = a p p l i c a t i o n . getCtrlDocument ( ) ;

f ina l Document doc = ctrlDocument . getReferenceDocument ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( documDetail ) ;

documDetail = new Window( ”Document Id : ” + doc . getDocumentId ( ) ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) documDetail . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

520f ina l DocumentHistory h i s t = new DocumentHistory ( ) ;

h i s t . setComment ( ”” ) ;

BeanItem<DocumentHistory> a l t I t em = new BeanItem<DocumentHistory>( h i s t ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm . setFormFieldFactory (new DocumentHistoryFieldFactory ( h i s t ) ) ;

modifyForm . setItemDataSource ( a l t I t em ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays

410

Page 429: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

530 . a s L i s t (new St r ing [ ] { ”comment” }) ) ;

p . addComponent (new Label ( ” Please exp la in the reason o f t h i s ac t i on ” ) ) ;

p . addComponent ( modifyForm ) ;

Button apply = new Button ( ”Save and c l o s e ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

modifyForm . commit ( ) ;

ctrlDocument . saveDocumentHistory ( h i s t ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( documDetail ) ;

540 }}) ;

Button c l o s e = new Button ( ” Close without sav ing ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

documDetail ) ;

}}) ;

550 Horizonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

btnLayout . addComponent ( c l o s e ) ;

p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

documDetail . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( documDetail ) ;

560 }

protected void showConfirmationComment ( f ina l DocActions act ) {ctrlDocument = a p p l i c a t i o n . getCtrlDocument ( ) ;

f ina l Document doc = ctrlDocument . getReferenceDocument ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( documDetail ) ;

documDetail = new Window( ”Document Id : ” + doc . getDocumentId ( ) ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) documDetail . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

570 p . s e tS i z eUnde f ined ( ) ;

f ina l DocumentHistory h i s t = new DocumentHistory ( ) ;

h i s t . setComment ( ”” ) ;

BeanItem<DocumentHistory> a l t I t em = new BeanItem<DocumentHistory>( h i s t ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm . setFormFieldFactory (new DocumentHistoryFieldFactory ( h i s t ) ) ;

modifyForm . setItemDataSource ( a l t I t em ) ;

580 modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays

. a s L i s t (new St r ing [ ] { ”comment” }) ) ;

p . addComponent (new Label ( ” Please exp la in the reason o f t h i s ac t i on ” ) ) ;

p . addComponent ( modifyForm ) ;

411

Page 430: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

Button apply = new Button ( ”Confirm” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

modifyForm . commit ( ) ;

try {590 ctrlDocument . applyAction ( act , h i s t ) ;

} catch ( SaveException e ) {e . pr intStackTrace ( ) ;

}}

}) ;

Button c l o s e = new Button ( ” Cancel ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( documDetail ) ;

}600 }) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

btnLayout . addComponent ( c l o s e ) ;

p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

documDetail . c en t e r ( ) ;

610 a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( documDetail ) ;

}

public void documentDeta i l sHistory ( ) {documentDetai ls ( true ) ;

}}

D.6.6 Classe EcoreDiagModifier.java

package i t . uniroma2 . norge . web ;

import i t . jaxb . e co re . E C l a s s i f i e r s ;

import i t . jaxb . e co re . EPackage ;

import i t . jaxb . e co re . EStructura lFeatures ;

import i t . jaxb . e co re . ESubpackages ;

import i t . jaxb . e co r ed i ag . Chi ldren ;

import i t . jaxb . e co r ed i ag . Diagram ;

import i t . jaxb . e co r ed i ag . Element ;

10 import i t . jaxb . e co r ed i ag . LayoutConstraint ;

import i t . jaxb . e co r ed i ag . S t y l e s ;

import i t . uniroma2 . norge . c o n t r o l l e r . F i l l o u t V a l i d a t i o n C t r l ;

import i t . uniroma2 . norge . model . jpa . Alternat iveAnswer ;

import i t . uniroma2 . norge . model . jpa . AnswerSet ;

import i t . uniroma2 . norge . model . jpa . Evidence ;

import i t . uniroma2 . norge . model . jpa . Mclass ;

import i t . uniroma2 . norge . model . jpa . Model ;

import i t . uniroma2 . norge . model . jpa . Mpackage ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

412

Page 431: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

20 import i t . uniroma2 . norge . model . jpa . Question ;

import i t . uniroma2 . norge . model . jpa . Quest ionna i re ;

import java . i o . BufferedInputStream ;

import java . i o . ByteArrayInputStream ;

import java . i o . ByteArrayOutputStream ;

import java . i o . IOException ;

import java . i o . Str ingReader ;

import java . i o . UnsupportedEncodingException ;

import java . math . B ig In tege r ;

30 import java . net . URLEncoder ;

import java . u t i l . HashMap ;

import java . u t i l . L i s t ;

import java . u t i l . Random ;

import java . u t i l . regex . Matcher ;

import java . u t i l . regex . Pattern ;

import java . u t i l . z ip . ZipEntry ;

import java . u t i l . z ip . ZipOutputStream ;

import javax . xml . bind . JAXBContext ;

40 import javax . xml . bind . JAXBException ;

import javax . xml . bind . Marsha l l e r ;

import javax . xml . bind . Unmarshal ler ;

import org . w3c . t idy . Tidy ;

public class EcoreDiagModi f ier {

private Agreement p r o j e c t ;

private Quest ionna i re q u e s t i o n n a i r e ;

50 private F i l l o u t V a l i d a t i o n C t r l q u e s t i o n n a i r e C t r l ;

private HashMap<Integer , AnswerSet> answers ;

private EPackage packages ;

private Diagram diagram ;

private St r ing newEcore ;

private St r ing newDiagram ;

private Model model ;

private HashMap<Str ing , Str ing> packageColors ;

private HashMap<Str ing , Str ing> c l a s s C o l o r s ;

private HashMap<Str ing , HashMap<Str ing , Str ing>> c l a s s A t t r i b u t e s ;

60 private HashMap<Str ing , Mpackage> nameToPkg ;

private St r ing ecoreFileName ;

public EcoreDiagModi f ier ( Agreement r e f e r e n c e P r o j e c t ,

F i l l o u t V a l i d a t i o n C t r l q u e s t i o n n a i r e C t r l ) {p r o j e c t = r e f e r e n c e P r o j e c t ;

q u e s t i o n n a i r e = p r o j e c t . ge tQues t i onna i r e ( ) ;

model = q u e s t i o n n a i r e . getModel ( ) ;

this . q u e s t i o n n a i r e C t r l = q u e s t i o n n a i r e C t r l ;

answers = new HashMap<Integer , AnswerSet >() ;

70 for ( Question q : q u e s t i o n n a i r e . getQuest ions ( ) ) {I n t e g e r i = q . getQuest ionId ( ) ;

AnswerSet a = this . q u e s t i o n n a i r e C t r l . getAnswerSetIsPresent ( i ) ;

answers . put ( i , a ) ;

}nameToPkg = new HashMap<Str ing , Mpackage>() ;

413

Page 432: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

for ( Mpackage p : model . getMpackages ( ) ) {nameToPkg . put (p . getName ( ) , p ) ;

}initXML ( ) ;

80 updateAndWriteXML ( ) ;

outXML( ) ;

}

private void initXML ( ) {St r ing o r i g i n a l E c o r e = q u e s t i o n n a i r e . getModel ( ) . getEcoreXml ( ) ;

S t r ing o r i g i n a l D i a g r = q u e s t i o n n a i r e . getModel ( ) . getEcorediagXml ( ) ;

try {i t . jaxb . e co re . ObjectFactory ofEcore = new i t . jaxb . e co re . ObjectFactory ( ) ;

90 JAXBContext contextDiag = JAXBContext . newInstance ( o fEcore

. ge tC la s s ( ) . getPackage ( ) . getName ( ) ) ;

Unmarshal ler unmarsha l l e r = contextDiag . c reateUnmarsha l l e r ( ) ;

S t r ing e c o r e F i l e 2 = new St r ing ( o r i g i n a l E c o r e ) ;

e c o r e F i l e 2 = e c o r e F i l e 2 . r e p l a c e ( ” x s i : type ” , ” x s i t y p e ” ) ;

e c o r e F i l e 2 = e c o r e F i l e 2 . r e p l a c e (

” http ://www. w3 . org /2001/XMLSchema−i n s t ance ” , ”INST” ) ;

e c o r e F i l e 2 = e c o r e F i l e 2 . r e p l a c e (

” ecore : EDataType http ://www. e c l i p s e . org /emf /2002/ Ecore#//” ,

”#//GenericPackage /” ) ;

100 packages = ( EPackage ) unmarsha l l er . unmarshal (new Str ingReader (

e c o r e F i l e 2 ) ) ;

} catch ( JAXBException e ) {e . pr intStackTrace ( ) ;

}

try {i t . jaxb . e co r ed i ag . ObjectFactory ofEcoreDiag = new

i t . jaxb . e co r ed i ag . ObjectFactory ( ) ;

JAXBContext contextDiag = JAXBContext . newInstance ( ofEcoreDiag

. ge tC la s s ( ) . getPackage ( ) . getName ( ) ) ;

110 Unmarshal ler unmarshal lerDiag = contextDiag . c reateUnmarsha l l e r ( ) ;

S t r ing eco r eDiagF i l e2 = new St r ing ( o r i g i n a l D i a g r ) ;

e co r eD iagF i l e2 = ecoreD iagF i l e2 . r e p l a c e ( ” xmi : ” , ” xmi ” ) ;

e co r eD iagF i l e2 = ecoreD iagF i l e2 . r e p l a c e ( ” x s i : n i l ” , ” x s i n i l ” ) ;

e co r eD iagF i l e2 = ecoreD iagF i l e2 . r e p l a c e ( ” x s i : n i l n i l ” , ” x s i n i l n i l ” ) ; //

i n u t i l e ?????

eco r eD iagF i l e2 = ecoreD iagF i l e2 . r e p l a c e (

” http ://www. w3 . org /2001/XMLSchema−i n s t ance ” ,

” http ://www. w3 . org /2001/XMLSchema−INST” ) ;

diagram = ( Diagram ) unmarshal lerDiag . unmarshal (new Str ingReader (

e co r eD iagF i l e2 ) ) ;

120 } catch ( JAXBException e ) {e . pr intStackTrace ( ) ;

}}

private void outXML( ) {try {

i t . jaxb . e co re . ObjectFactory ofEcore = new i t . jaxb . e co re . ObjectFactory ( ) ;

JAXBContext contextDiag = JAXBContext . newInstance ( o fEcore

. ge tC la s s ( ) . getPackage ( ) . getName ( ) ) ;

414

Page 433: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

130 Marsha l l e r mar sha l l e r = contextDiag . c r ea t eMar sha l l e r ( ) ;

ByteArrayOutputStream myOutputStream = new ByteArrayOutputStream ( ) ;

mar sha l l e r . marshal ( packages , myOutputStream ) ;

newEcore = new St r ing ( myOutputStream . toByteArray ( ) ) ;

newEcore = newEcore . r e p l a c e ( ”ns4” , ” ecore ” ) ;

newEcore = newEcore . r e p l a c e ( ”ns3” , ”xmi” ) ;

newEcore = newEcore . r e p l a c e ( ”ns2” , ” x s i ” ) ;

newEcore = newEcore . r e p l a c e ( ” x s i t y p e ” , ” x s i : type ” ) ;

newEcore = newEcore . r e p l a c e ( ”INST” ,

” http ://www. w3 . org /2001/XMLSchema−i n s t ance ” ) ;

140 newEcore = newEcore . r e p l a c e ( ”#//GenericPackage /” ,

” ecore : EDataType http ://www. e c l i p s e . org /emf /2002/ Ecore#//” ) ;

ByteArrayInputStream i s = new ByteArrayInputStream ( newEcore

. getBytes ( ) ) ;

ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ;

Tidy t idy = new Tidy ( ) ;

// [ Tidy : Reindent XML] from notepad++ p l u g i n

// input−xml : yes

150 // indent : yes

t idy . s e t In de n tA t t r i bu t e s ( fa l se ) ;

t idy . set IndentContent ( true ) ;

t idy . setXmlTags ( true ) ;

t idy . setXmlOut ( true ) ;

t idy . parseDOM( i s , os ) ;

newEcore = new St r ing ( os . toByteArray ( ) ) ;

} catch ( JAXBException e ) {e . pr intStackTrace ( ) ;

160 }try {

i t . jaxb . e co r ed i ag . ObjectFactory ofEcoreDiag = new

i t . jaxb . e co r ed i ag . ObjectFactory ( ) ;

JAXBContext contextDiag = JAXBContext . newInstance ( ofEcoreDiag

. ge tC la s s ( ) . getPackage ( ) . getName ( ) ) ;

Marsha l l e r mar sha l l e r = contextDiag . c r ea t eMar sha l l e r ( ) ;

ByteArrayOutputStream myOutputStream = new ByteArrayOutputStream ( ) ;

mar sha l l e r . marshal ( diagram , myOutputStream ) ;

newDiagram = new St r ing ( myOutputStream . toByteArray ( ) ) ;

newDiagram = newDiagram . r e p l a c e ( ”ns4” , ” notat ion ” ) ;

170 newDiagram = newDiagram . r e p l a c e ( ”ns3” , ”xmi” ) ;

newDiagram = newDiagram . r e p l a c e ( ”ns2” , ” x s i ” ) ;

newDiagram = newDiagram . r e p l a c e ( ” xmi ” , ” xmi : ” ) ;

newDiagram = newDiagram . r e p l a c e ( ” x s i n i l n i l ” , ” x s i : n i l n i l ” ) ; // i n u t i l e ?????

newDiagram = newDiagram . r e p l a c e ( ” x s i n i l ” , ” x s i : n i l ” ) ;

newDiagram = newDiagram . r e p l a c e (

” http ://www. w3 . org /2001/XMLSchema−INST” ,

” http ://www. w3 . org /2001/XMLSchema−i n s t ance ” ) ;

S t r ing from = ”xmlns : xmi=\”http ://www. omg . org /XMI\”” ;

S t r ing tmp = ”xmlns : e co re=\”http ://www. e c l i p s e . org /emf /2002/ Ecore \”” ;

180 newDiagram = newDiagram . r e p l a c e ( from , from + ” ” + tmp) ;

ecoreFileName = ” i dont know . eco re ” ;

Pattern pattern = Pattern

. compi le ( ” h r e f =\”([a−zA−Z0−9\\ \\ .\\ %]+)+(#//)” ) ;

415

Page 434: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

// S t r i n g input = ”<element xmi : type=\”ecore : EAttr ibu te \” ”

// + ” h r e f =\”SysML%20Model M . ecore#//Art i fac tConcep t s /”

// + ” A r t i f a c t / s t a t e \”/>”;

Matcher matcher = pattern . matcher ( newDiagram ) ;

i f ( matcher . f i n d ( ) ) {190 // System . out . p r i n t l n ( matcher . s t a r t ( ) ) ;

// System . out . p r i n t l n ( matcher . end () ) ;

// System . out . p r i n t l n ( matcher . group () ) ;

ecoreFileName = matcher . group ( ) ;

System . out . p r i n t l n ( ecoreFileName ) ;

pattern = Pattern . compi le ( ”\”.+#” ) ;

Matcher matcher2 = pattern . matcher ( ecoreFileName ) ;

i f ( matcher2 . f i n d ( ) ) {ecoreFileName = matcher2 . group ( ) ;

System . out . p r i n t l n ( ecoreFileName ) ;

200 ecoreFileName = ecoreFileName . su b s t r i n g (1 , matcher2 . group ( )

. l ength ( ) − 1) ;

ecoreFileName = matcher2 . group ( ) ;

System . out . p r i n t l n ( ecoreFileName ) ;

ecoreFileName = ecoreFileName . su b s t r i n g ( ecoreFileName

. indexOf ( ’ ” ’ ) + 1 , ecoreFileName . indexOf ( ’#’ ) ) ;

System . out . p r i n t l n ( ecoreFileName ) ;

try {ecoreFileName = java . net . URLDecoder . decode (

ecoreFileName , ”UTF−8” ) ;

210 } catch ( UnsupportedEncodingException e ) {}System . out . p r i n t l n ( ecoreFileName ) ;

}}

ByteArrayInputStream i s = new ByteArrayInputStream ( newDiagram

. getBytes ( ) ) ;

ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ;

220 Tidy t idy = new Tidy ( ) ;

// [ Tidy : Reindent XML] from notepad++ p l u g i n

// input−xml : yes

// indent : yes

t idy . s e t In de n tA t t r i bu t e s ( fa l se ) ;

t idy . set IndentContent ( true ) ;

t idy . setXmlTags ( true ) ;

t idy . setXmlOut ( true ) ;

t idy . parseDOM( i s , os ) ;

newDiagram = new St r ing ( os . toByteArray ( ) ) ;

230} catch ( JAXBException e ) {

e . pr intStackTrace ( ) ;

}}

private void updateAndWriteXML ( ) {// ALGORITMO FONDAMENTALE

// − per ogni domanda ho una l i s t a d i r i s p o s t e con l e r e l a t i v e

// v a l i d a z i o n i

240 // − devo agg iungere i l f i e l d n e l l a c l a s s e per ogni r i s p o s t a

416

Page 435: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

// − devo agg iungere i l box ne l diagramma d e l l a c l a s s e per ogni r i s p o s t a

// − devo impostare i l c o l o r e d i s fondo d e l l a c l a s s e in base a l l a

// v a l i d a z i o n e d e l l a domanda

// − l a g r a f i c a d i un a t t r i b u t o non s i puo modi f i care qu ind i va messo

// ne l nome anche l o s t a t o

// − per l e f r e c c e s i puo mettere i l c o l o r e per l o ma non i l nome

// ( andrebbe

// messo come a t t r i b u t o d e l l a c l a s s e d e s t i n a t a r i a )

250 packageColors = new HashMap<Str ing , Str ing >() ;

c l a s s C o l o r s = new HashMap<Str ing , Str ing >() ;

c l a s s A t t r i b u t e s = new HashMap<Str ing , HashMap<Str ing , Str ing >>() ;

L i s t<Mpackage> pkgs = model . getMpackages ( ) ;

for ( Mpackage pkg : pkgs ) {packageColors . put ( pkg . getCanonicalName ( ) , null ) ;

L i s t<Mclass> c l s s = pkg . getMc las se s ( ) ;

for ( Mclass c l s : c l s s ) {c l a s s C o l o r s . put ( c l s . getCanonicalName ( ) , null ) ;

260 }}

for ( I n t e g e r i : answers . keySet ( ) ) {AnswerSet a = answers . get ( i ) ;

i f ( a != null ) {St r ing c l s = a . getQuest ion ( ) . getMclass ( ) . getCanonicalName ( ) ;

S t r ing pkg = a . getQuest ion ( ) . getMclass ( ) . getMpackage ( )

. getCanonicalName ( ) ;

HashMap<Str ing , Str ing> a t t r s = new HashMap<Str ing , Str ing >() ;

270 for ( Alternat iveAnswer aa : a . getQuest ion ( )

. getAlternat iveAnswers ( ) ) {St r ing r = aa . getAnswer ( ) ;

S t r ing s t a t e = ” n u l l ” ;

a t t r s . put ( r , s t a t e ) ;

}for ( Evidence aa : a . getAnswsetAnsws ( ) ) {

St r ing r = aa . getAlternat iveAnswer ( ) . getAnswer ( ) ;

S t r ing s t a t e = aa . getApprovat ionStatus ( ) ;

a t t r s . put ( r , s t a t e ) ;

280 }St r ing open = a . getQuest ion ( ) . getOpenQuestion ( ) ;

i f ( open != null && open . equa l s ( ” yes ” ) ) {St r ing r = a . getOpenAnswer ( ) ;

S t r ing s t a t e = a . getApprovat ionStatus ( ) ;

a t t r s . put ( r , s t a t e ) ;

}c l a s s A t t r i b u t e s . put ( c l s , a t t r s ) ;

c l a s s C o l o r s . put ( c l s , a . getApprovat ionStatusFina l ( ) ) ;

S t r ing s t a t e = packageColors . get ( pkg ) ;

290 s t a t e = a . getApprovat ionStatusFina l ( ) ;

packageColors . put ( pkg , s t a t e ) ;

}}updateEcoreTree ( ) ;

updateDiagramTree ( ) ;

}

417

Page 436: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private void updateEcoreTree ( ) {St r ing canoNamePkg ;

300 St r ing canoNameCls ;

for ( ESubpackages sp : packages . getESubpackages ( ) ) {canoNamePkg = ”#//” + sp . getName ( ) ;

for ( E C l a s s i f i e r s c : sp . g e t E C l a s s i f i e r s ( ) ) {i f ( c . getXsiType ( ) . conta in s ( ” EClass ” ) ) {

canoNameCls = canoNamePkg + ”/” + c . getName ( ) ;

i f ( c l a s s A t t r i b u t e s . containsKey ( canoNameCls ) ) {HashMap<Str ing , Str ing> a t t r s = c l a s s A t t r i b u t e s

. get ( canoNameCls ) ;

L i s t<EStructura lFeatures> p r e e x i s t A t t r s = c

310 . g e tESt ruc tura lFeature s ( ) ;

for ( S t r ing a t t r : a t t r s . keySet ( ) ) {St r ing s t a t e = a t t r s . get ( a t t r ) ;

EStructura lFeatures a = c l a s sA t t r i bu t eFac t o ry ( ) ;

a . setName ( toAttributeNAme ( att r , s t a t e ) ) ;

p r e e x i s t A t t r s . add ( a ) ;

}} else {

System . out . p r i n t l n ( ”Nessun a t t r i b u t o per l a c l a s s e ”

+ canoNameCls ) ;

320 }}

}}

}

private St r ing toAttributeNAme ( St r ing att r , S t r ing s t a t e ) {St r ing a t t r 2 = ”” ;

S t r ing s t a t e 2 = ”” ;

try {330 a t t r 2 = URLEncoder . encode ( att r , ”UTF−8” ) ;

s t a t e 2 = URLEncoder . encode ( s ta te , ”UTF−8” ) ;

} catch ( UnsupportedEncodingException e ) {}return a t t r 2 + ” ( ” + s t a t e 2 + ” ) ” ;

}

private EStructura lFeature s c l a s sAt t r i bu t e Fac to r y ( ) {EStructura lFeatures e = new EStructura lFeatures ( ) ;

e . setXsiType ( ” eco re : EReference ” ) ;

340 return e ;

}

private void updateDiagramTree ( ) {for ( Chi ldren chd : diagram . getChi ldren ( ) ) {

manageChildren ( chd ) ;

}}

private void manageChildren ( Chi ldren chd ) {350 // 1002 e i l package −> g e s t i o n e f i g l i + c o l o r e

// −−4006 ???

// −−5003 e l ’ insieme d e l l e c l a s s i −> g e s t i o n e f i g l i

418

Page 437: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

// −−−−2003 e l a c l a s s e −> c o l o r e + g e s t i o n e f i g l i

// −−−−−−4002 ???

// −−−−−−5004 sono g l i a t t r i b u t i d e l l a c l a s s e −> agg iunta a t t r i b u t i

// −−−−−−−−2001 i l s i n g o l o a t t i b u t o

// −−−−−−5005 sono l e o p e r a z i o n i ?????

//

// verde = 65280

360 // rosso = 255

// g i a l l o = 65535

// b l u = 16711680

// c e l e s t e = 16755242

// f u c s i a = 13904639

// nero = 0

i f ( chd . getChildrenType ( ) . intValue ( ) == 4006) {// nothing

} else i f ( chd . getChildrenType ( ) . intValue ( ) == 4002) {// nothing

370 } else i f ( chd . getChildrenType ( ) . intValue ( ) == 5005) {// nothing

} else i f ( chd . getChildrenType ( ) . intValue ( ) == 2003) {// manageClass ( chd ) ;

// SET CLASS COLOR accordin to VALIDATION

for ( S t y l e s s : chd . g e t S t y l e s ( ) )

i f ( s . getXmiType ( ) . equa l s IgnoreCase ( ” notat ion : ShapeStyle ” ) )

s . s e t F i l l C o l o r (new Big Intege r ( ”65280” ) ) ;

} else i f ( chd . getChildrenType ( ) . intValue ( ) == 1002) {for ( Chi ldren chd2 : chd . getChi ldren ( ) )

380 manageChildren ( chd2 ) ;

// SET PACKAGE COLOR accordin to VALIDATION

for ( S t y l e s s : chd . g e t S t y l e s ( ) )

i f ( s . getXmiType ( ) . equa l s IgnoreCase ( ” notat ion : ShapeStyle ” ) )

s . s e t F i l l C o l o r (new Big Intege r ( ”65280” ) ) ;

} else {for ( Chi ldren chd2 : chd . getChi ldren ( ) )

manageChildren ( chd2 ) ;

}}

390@SuppressWarnings ( ”unused” )

private void manageClass ( Chi ldren chd ) {St r ing canoName = chd . getElement ( ) . getHre f ( ) ;

// S t r i n g x = ”SysML%20Model M . ecore#//Art i fac tConcep t s / A r t i f a c t ” ;

canoName = canoName . s ub s t r i ng ( canoName . indexOf ( ”#//” ) ) ;

i f ( c l a s s A t t r i b u t e s . containsKey ( canoName) ) {HashMap<Str ing , Str ing> toCreate = c l a s s A t t r i b u t e s . get ( canoName) ;

for ( Chi ldren a t t r i b u t e s : chd . getChi ldren ( ) ) {i f ( a t t r i b u t e s . getChildrenType ( ) . intValue ( ) == 5004) {

400 for ( S t r ing a t t r : toCreate . keySet ( ) ) {St r ing s t a t e = toCreate . get ( a t t r ) ;

Chi ldren attrC = diagramAttr ibuteFactory ( att r , s ta te ,

canoName) ;

a t t r i b u t e s . ge tChi ldren ( ) . add ( attrC ) ;

}}

}}

419

Page 438: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}410

private Chi ldren diagramAttr ibuteFactory ( S t r ing att r , S t r ing s tate ,

S t r ing canoName) {Chi ldren c = new Chi ldren ( ) ;

c . setXmiType ( ” notat ion : Node” ) ;

c . setChi ldrenType (new Big Intege r ( ”2001” ) ) ;

c . setElement (new Element ( ) ) ;

c . getElement ( ) . setXmiType ( ” eco re : EAttr ibute ” ) ;

S t r ing h r e f = canoName ;

h r e f += ”#//” + toAttributeNAme ( att r , s t a t e ) ;

420 c . getElement ( ) . s e tHre f ( h r e f ) ;

c . se tLayoutConstra int (new LayoutConstraint ( ) ) ;

c . getLayoutConstra int ( ) . setXmiType ( ” notat ion : Locat ion ” ) ;

// Tu7xkAm Ed−TScDWDXYp w

St r ing id1 = ” ” + randStr ing (7 ) + ” Ed−” + randStr ing (9 ) + ” w” ;

S t r ing id2 = ” ” + randStr ing (7 ) + ” Ed−” + randStr ing (9 ) + ” w” ;

c . setXmiId ( id1 ) ;

c . getLayoutConstra int ( ) . setXmiId ( id2 ) ;

return null ;

}430

private St r ing randStr ing ( int i ) {St r ing r e s = ”” ;

Random RNG = new Random( ) ;

for ( int j = 0 ; j < i ; j++) {char c = (char ) (RNG. next Int ( Character .MAX VALUE + 1) ) ;

r e s += c ;

}return r e s ;

}440

public byte [ ] getEcore ( ) {return newEcore . getBytes ( ) ;

}

public byte [ ] getDiagram ( ) {return newDiagram . getBytes ( ) ;

}

stat ic f ina l int BUFFER = 2048 ;

450public byte [ ] getZip ( ) {

BufferedInputStream o r i g i n = null ;

ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ;

ZipOutputStream out = new ZipOutputStream ( os ) ;

ByteArrayInputStream f i = new ByteArrayInputStream ( newEcore . getBytes ( ) ) ;

o r i g i n = new BufferedInputStream ( f i , BUFFER) ;

460 try {byte data [ ] = new byte [BUFFER] ;

ZipEntry entry = new ZipEntry ( ecoreFileName ) ;

out . putNextEntry ( entry ) ;

int count ;

420

Page 439: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

while ( ( count = o r i g i n . read ( data , 0 , BUFFER) ) != −1) {out . wr i t e ( data , 0 , count ) ;

}o r i g i n . c l o s e ( ) ;

} catch ( IOException e ) {470 e . pr intStackTrace ( ) ;

}

f i = new ByteArrayInputStream ( newDiagram . getBytes ( ) ) ;

try {byte data [ ] = new byte [BUFFER] ;

o r i g i n = new BufferedInputStream ( f i , BUFFER) ;

ZipEntry entry = new ZipEntry ( ”Model . e co r ed i ag ” ) ;

out . putNextEntry ( entry ) ;

int count ;

480 while ( ( count = o r i g i n . read ( data , 0 , BUFFER) ) != −1) {out . wr i t e ( data , 0 , count ) ;

}o r i g i n . c l o s e ( ) ;

} catch ( IOException e ) {e . pr intStackTrace ( ) ;

}try {

out . c l o s e ( ) ;

} catch ( IOException e ) {490 e . pr intStackTrace ( ) ;

}return os . toByteArray ( ) ;

}}

D.6.7 Classe FilloutValidationUI.java

package i t . uniroma2 . norge . web ;

import i t . uniroma2 . norge . common . Quest ionStatus ;

import i t . uniroma2 . norge . c o n t r o l l e r . LoggedUser ;

import i t . uniroma2 . norge . c o n t r o l l e r . F i l l o u t V a l i d a t i o n C t r l ;

import i t . uniroma2 . norge . c o n t r o l l e r . F i l l o u t V a l i d a t i o n C t r l . MpackageRank ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

import i t . uniroma2 . norge . model . jpa . AnswerSet ;

import i t . uniroma2 . norge . model . jpa . AnswsetHistory ;

10 import i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e ;

import i t . uniroma2 . norge . model . jpa . De l ive rab l eContentHi s to ry ;

import i t . uniroma2 . norge . model . jpa . De l ive rab l eEv idence ;

import i t . uniroma2 . norge . model . jpa . Evidence ;

import i t . uniroma2 . norge . model . jpa . Mclass ;

import i t . uniroma2 . norge . model . jpa . Mpackage ;

import i t . uniroma2 . norge . model . jpa . Question ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . AnswerHistoryFie ldFactory ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . AnswerSetFie ldFactory ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . De l ivContentHis toryFie ldFactory ;

20 import i t . uniroma2 . norge . web . support . EvidenceMapBean ;

import i t . uniroma2 . norge . web . support . ExclusionBean ;

421

Page 440: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import i t . uniroma2 . norge . web . support . F i l l i ngBean ;

import java . t ex t . SimpleDateFormat ;

import java . u t i l . ArrayList ;

import java . u t i l . Arrays ;

import java . u t i l . C o l l e c t i o n s ;

import java . u t i l . Comparator ;

import java . u t i l . Date ;

30 import java . u t i l . HashMap ;

import java . u t i l . LinkedHashMap ;

import java . u t i l . L inkedLis t ;

import java . u t i l . L i s t ;

import com . vaadin . addon . t r e e t a b l e . TreeTable ;

import com . vaadin . data . Item ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . data . u t i l . BeanItem ;

40 import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . t e rmina l . S i z e a b l e ;

import com . vaadin . u i . Alignment ;

import com . vaadin . u i . Button ;

import com . vaadin . u i . CheckBox ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . ComponentContainer ;

import com . vaadin . u i . Embedded ;

import com . vaadin . u i . Form ;

import com . vaadin . u i . GridLayout ;

50 import com . vaadin . u i . Hor izonta lLayout ;

import com . vaadin . u i . Label ;

import com . vaadin . u i . Link ;

import com . vaadin . u i . Nat i v eSe l e c t ;

import com . vaadin . u i . Panel ;

import com . vaadin . u i . PopupView ;

import com . vaadin . u i . Table ;

import com . vaadin . u i . Tree ;

import com . vaadin . u i . Vert i ca lLayout ;

import com . vaadin . u i . Window ;

60 import com . vaadin . u i . Button . Cl ickEvent ;

import com . vaadin . u i . Button . C l i c k L i s t e n e r ;

import com . vaadin . u i . Table . ColumnGenerator ;

import com . vaadin . u i . Window . N o t i f i c a t i o n ;

public class F i l l ou tV a l i da t i o nU I {

private TesiwebAppl icat ion a p p l i c a t i o n ;

private F i l l o u t V a l i d a t i o n C t r l c t r l Q u e s t i o n n a i r e ;

70private Vert i ca lLayout body ;

private GridLayout quest ionGridL ;

private BeanItemContainer<AnswerSet> quest ionsDataSource ;

public Table quest ionsTab le ;

422

Page 441: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public Table answersTable ;

public Table ru le sExc luTable ;

80 public Table rulesMultTable ;

public Nat iveSe l e c t p r o j e c t L i s t ;

private Window qstDtlAnswering ;

private Vert i ca lLayout rulesExclTxtArea ;

private Vert i ca lLayout rulesMultTxtArea ;

90 public Nat iveSe l e c t packageLis t ;

private Window qstEvidMap ;

private St r ing de f in i t i onOfContex t = ” D e f i n i t i o n o f C o n t e x t ” ;

public F i l l o u tV a l i da t i o nU I ( Tes iwebAppl icat ion appl ) {this . a p p l i c a t i o n = appl ;

c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

body = a p p l i c a t i o n . getBody ( ) ;

100 }

public void p r o j e c t s L i s t ( ) {c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

LoggedUser user = ( LoggedUser ) a p p l i c a t i o n . getUser ( ) ;

a p p l i c a t i o n . setArea ( ”” ) ;

body . removeAllComponents ( ) ;

Panel p = new Panel ( ”Agreements” ) ;

p . s e t S i z e F u l l ( ) ;

quest ionGridL = new GridLayout (3 , 3) ;

110 quest ionGridL . se tSpac ing ( true ) ;

quest ionGridL . setMargin ( fa l se ) ;

quest ionGridL . s e t S i z e F u l l ( ) ;

body . addComponent ( quest ionGridL ) ;

body . setComponentAlignment ( questionGridL , Alignment .TOP CENTER) ;

p r o j e c t L i s t = new Nat iveSe l e c t ( ” Please s e l e c t the agreement ” ) ;

L i s t<Agreement> datas = user . p ro j e c t sForRo l e ( ” s u p p l i e r ” ) ;

BeanItemContainer<Agreement> ds = new BeanItemContainer<Agreement>(datas ) ;

p r o j e c t L i s t . setContainerDataSource ( ds ) ;

120 p r o j e c t L i s t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

p r o j e c t L i s t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

p r o j e c t L i s t . setValue ( ”” ) ;

p r o j e c t L i s t . setImmediate ( true ) ;

p r o j e c t L i s t . addLis tener ( c t r l Q u e s t i o n n a i r e ) ;

quest ionGridL . addComponent (p , 0 , 0) ;

p . addComponent ( p r o j e c t L i s t ) ;

quest ionGridL . setComponentAlignment (p , Alignment .TOP CENTER) ;

130 }

public void packagesL i s t ( ) {c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

423

Page 442: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

Vert i ca lLayout v l = new Vert i ca lLayout ( ) ;

v l . s e t S i z e F u l l ( ) ;

quest ionGridL . removeComponent (0 , 1) ;

quest ionGridL . addComponent ( vl , 0 , 1 , 2 , 1) ;

Panel pkg = new Panel ( ” Packages ” ) ;

140 pkg . s e t S i z e F u l l ( ) ;

quest ionGridL . removeComponent (2 , 0) ;

quest ionGridL . addComponent ( pkg , 2 , 0) ;

quest ionGridL . setComponentAlignment ( pkg , Alignment .TOP CENTER) ;

i f ( c t r l Q u e s t i o n n a i r e . i s S i l Q u e s t i o n n a i r e ( ) ) {Panel s i l = new Panel ( ”SIL l e v e l to be achieved ” ) ;

s i l . s e t S i z e F u l l ( ) ;

quest ionGridL . removeComponent (1 , 0) ;

150 St r ing tmp = c t r l Q u e s t i o n n a i r e . a c t u a l S i l L e v e l ( ) ;

i f (tmp == null )

tmp = ”SIL not s p e c i f i e d ” ;

else

tmp = ” Actual SIL l e v e l i s ” + tmp ;

s i l . addComponent (new Label (tmp) ) ;

Button b = new Button ( ”Change SIL l e v e l ” ) ;

b . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {160 c t r l Q u e s t i o n n a i r e . q u e s t i o n S i l D e t a i l s ( ) ;

}}) ;

s i l . addComponent (b) ;

}

List<MpackageRank> datas = c t r l Q u e s t i o n n a i r e . getListDataMpackage ( ) ;

packageLis t = new Nat iveSe l e c t (

” S e l e c t package to see r e l a t e d que s t i on s ” ) ;

170 LinkedList<Mpackage> datas2 = new LinkedList<Mpackage>() ;

for ( MpackageRank m : datas )

datas2 . add (m. getMpackage ( ) ) ;

BeanItemContainer<Mpackage> ds = new BeanItemContainer<Mpackage>(datas2 ) ;

packageLis t . setContainerDataSource ( ds ) ;

packageLis t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

packageLis t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

packageLis t . setValue ( ”” ) ;

packageLis t . setImmediate ( true ) ;

180 packageLis t . addLis tener ( c t r l Q u e s t i o n n a i r e . g e t P a c k a g e F i l l i n g S e l e c t e d ( ) ) ;

pkg . addComponent ( packageLis t ) ;

Panel p1 = new Panel ( ” Overa l l s t a t u s ” ) ;

p1 . s e tS i z eUnde f ined ( ) ;

p1 . setContent (new Horizonta lLayout ( ) ) ;

Embedded embedded1a = new Embedded( ”” , c t r l Q u e s t i o n n a i r e . exportPie1 ( ) ) ;

Embedded embedded2a = new Embedded( ”” , c t r l Q u e s t i o n n a i r e . exportPie2 ( ) ) ;

Embedded embedded3a = new Embedded( ”” , c t r l Q u e s t i o n n a i r e . exportPie3 ( ) ) ;

424

Page 443: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

190 p1 . addComponent ( embedded3a ) ;

p1 . addComponent ( embedded1a ) ;

p1 . addComponent ( embedded2a ) ;

v l . addComponent ( p1 ) ;

v l . setComponentAlignment ( p1 , Alignment .TOP CENTER) ;

i f ( datas != null && datas . s i z e ( ) > 0) {for ( f ina l MpackageRank pr : datas ) {

Panel p = new Panel ( pr . getMpackage ( ) . getCanonicalName ( )

+ ” ( p r i o r i t y ” + pr . getRank ( ) + ” ) ” ) ;

p . s e tS i z eUnde f ined ( ) ;

200 p . setContent (new Horizonta lLayout ( ) ) ;

Button embedded1 = new Button ( ) ;

embedded1 . s e t I c on ( c t r l Q u e s t i o n n a i r e . exportPieQPackage ( pr

. getMpackage ( ) ) ) ;

Button embedded2 = new Button ( ) ;

embedded2 . s e t I c on ( c t r l Q u e s t i o n n a i r e . exportPieAPackage ( pr

. getMpackage ( ) ) ) ;

Button embedded3 = new Button ( ) ;

embedded3 . s e t I c on ( c t r l Q u e s t i o n n a i r e . exportPieDPackage ( pr

. getMpackage ( ) ) ) ;

210 C l i c k L i s t e n e r c = new C l i c k L i s t e n e r ( ) {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Override

public void buttonCl ick ( ClickEvent event ) {c t r l Q u e s t i o n n a i r e . packageSe lec ted ( pr . getMpackage ( ) ) ;

}} ;

embedded1 . addLis tener ( c ) ;

embedded2 . addLis tener ( c ) ;

220 embedded3 . addLis tener ( c ) ;

i f ( ! pr . getMpackage ( ) . getCanonicalName ( ) . conta in s (

de f in i t i onOfContex t ) ) {p . addComponent ( embedded3 ) ;

}p . addComponent ( embedded1 ) ;

i f ( ! pr . getMpackage ( ) . getCanonicalName ( ) . conta in s (

de f in i t i onOfContex t ) ) {p . addComponent ( embedded2 ) ;

}230 v l . addComponent (p) ;

v l . setComponentAlignment (p , Alignment .TOP CENTER) ;

}}quest ionGridL . r eques tRepa intAl l ( ) ;

}

public void q u e s t i o n s L i s t ( ) {c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

Vert i ca lLayout p = new Vert i ca lLayout ( ) ;

240 p . setMargin ( fa l se ) ;

p . s e tS i z eUnde f ined ( ) ;

quest ionGridL . removeComponent (0 , 1) ;

quest ionGridL . addComponent (p , 0 , 1 , 2 , 1) ;

ques t ionsTab le = new Table ( ) ;

425

Page 444: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

quest ionsTab le . s e t S e l e c t a b l e ( true ) ;

ques t ionsTab le . setImmediate ( true ) ;

L i s t<AnswerSet> datas = c t r l Q u e s t i o n n a i r e . getListDataAnswer ( ) ;

i f ( datas . s i z e ( ) > 0) {250 quest ionsDataSource = new BeanItemContainer<AnswerSet>(datas ) ;

ques t ionsTab le . setContainerDataSource ( quest ionsDataSource ) ;

ques t ionsTab le . setColumnReorderingAllowed ( true ) ;

ques t ionsTab le . setColumnCollapsingAllowed ( fa l se ) ;

int x = 20 ;

i f ( datas . s i z e ( ) < x )

x = datas . s i z e ( ) ;

ques t ionsTab le . s o r t (new Object [ ] { ” ranking ” } ,

new boolean [ ] { true }) ;

ques t ionsTab le . setPageLength ( x ) ;

260 quest ionsTab le . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

ques t ionsTab le . s e t M u l t i S e l e c t ( fa l se ) ;

ques t ionsTab le . addGeneratedColumn ( ”Agreement on Evidence ” ,

new Table . ColumnGenerator ( ) {public Component g e n e r a t e Ce l l ( Table source ,

Object itemId , Object columnId ) {Item item = quest ionsTab le . getItem ( itemId ) ;

f ina l I n t e g e r qid = ( I n t e g e r ) item . getItemProperty (

” answerSetId ” ) . getValue ( ) ;

270 Button b = new Button ( ” His tory ” ) ;

b . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {r e f r e s h Q u e s t i o n L i s t ( ) ;

c t r l Q u e s t i o n n a i r e

. q u e s t i o n S e l e c t e d H i s t o r y ( qid ) ;

}}) ;

280 Button b2 = null ;

b2 = new Button ( ”Answer” ) ;

b2 . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {r e f r e s h Q u e s t i o n L i s t ( ) ;

c t r l Q u e s t i o n n a i r e

. q u e s t i o n S e l e c t e d D e t a i l s ( qid ) ;

}}) ;

290 Horizonta lLayout l = new Horizonta lLayout ( ) ;

i f ( ! c t r l Q u e s t i o n n a i r e . getReferencePackage ( )

. getCanonicalName ( ) . conta in s (

de f in i t i onOfContex t ) )

l . addComponent (b) ;

l . addComponent ( b2 ) ;

return l ;

}}) ;

i f ( ! c t r l Q u e s t i o n n a i r e . getReferencePackage ( ) . getCanonicalName ( )

300 . c onta in s ( de f in i t i onOfContex t ) )

ques t ionsTab le . addGeneratedColumn ( ”Agreement on D e l i v e r a b l e s ” ,

426

Page 445: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

new Table . ColumnGenerator ( ) {public Component g e n e r a t e C e l l ( Table source ,

Object itemId , Object columnId ) {Item item = quest ionsTab le . getItem ( itemId ) ;

f ina l St r ing s t a t u s = ( St r ing ) item

. getItemProperty (

” approvat ionStatusF ina l ” )

. getValue ( ) ;

310 i f ( s t a t u s == null

| | s t a t u s

. equa l s IgnoreCase ( Quest ionStatus .TO SPECIFY) )

return new Label ( ”” ) ;

f ina l I n t e g e r qid = ( I n t e g e r ) item

. getItemProperty ( ” answerSetId ” )

. getValue ( ) ;

Button b = new Button ( ” His tory ” ) ;

b . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

320 public void buttonCl ick ( ClickEvent event ) {r e f r e s h Q u e s t i o n L i s t ( ) ;

c t r l Q u e s t i o n n a i r e

. que s t i onSe l e c t edEv idenceH i s to ry ( qid ) ;

}}) ;

Button b2 = new Button ( ” Proposal ” ) ;

b2 . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {330 r e f r e s h Q u e s t i o n L i s t ( ) ;

c t r l Q u e s t i o n n a i r e

. que s t i onSe l e c t edEv idence ( qid ) ;

}}) ;

Hor izonta lLayout l = new Horizonta lLayout ( ) ;

i f ( item . getItemProperty ( ” ques t i on ” ) != null ) {f ina l Question q = ( Question ) item

. getItemProperty ( ” ques t i on ” ) . getValue ( ) ;

i f ( q . ge tRe la t i on ( ) == null ) {340 l . addComponent (b) ;

l . addComponent ( b2 ) ;

}}return l ;

}}) ;

i f ( datas . s i z e ( ) > 0) {i f ( ! c t r l Q u e s t i o n n a i r e . getReferencePackage ( ) . getCanonicalName ( )

. conta in s ( de f in i t i onOfContex t ) ) {350 quest ionsTab le . setVis ib leColumns (new Object [ ] { ” ranking ” ,

” quest ionText ” , ” f i n a l S t a t u s ” ,

” approvat ionStatusF ina l ” , ”Agreement on Evidence ” ,

” de l ivApprovat ionStatus ” ,

”Agreement on D e l i v e r a b l e s ” }) ;

ques t ionsTab le . setColumnHeaders (new St r ing [ ] { ” P r i o r i t y ” ,

” Question ” , ” Fina l Status ” , ” Evidence Status ” ,

”Agreement on Evidence ” , ” Del iv . Status ” ,

427

Page 446: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

”Agreement on D e l i v e r a b l e s ” }) ;

} else {360 quest ionsTab le . setVis ib leColumns (new Object [ ] { ” ranking ” ,

” quest ionText ” , ”Agreement on Evidence ” }) ;

ques t ionsTab le . setColumnHeaders (new St r ing [ ] { ” P r i o r i t y ” ,

” Question ” , ”Answer” }) ;

}

}quest ionsTab le

. s e t C e l l S ty l e Ge n e r a t o r (new Table . Ce l lS ty l eGenera to r ( ) {public St r ing g e t S t y l e ( Object itemId , Object propertyId ) {

370 i f ( propertyId == null | | i temId == null ) {return null ;

} else i f ( propertyId

. equa l s ( ” approvat ionStatusF ina l ” ) ) {Item item = quest ionsTab le . getItem ( itemId ) ;

f ina l St r ing s = ( St r ing ) item . getItemProperty (

” approvat ionStatusF ina l ” ) . getValue ( ) ;

i f ( s == null )

return null ;

else i f ( s . equa l s ( Quest ionStatus .TO SPECIFY) )

380 return ” orange ” ;

else i f ( s

. equa l s ( Quest ionStatus .YET TO ANALYZE) )

return ” ye l low ” ;

else i f ( s . equa l s ( Quest ionStatus .ACCEPTED) )

return ” green ” ;

else i f ( s . equa l s ( Quest ionStatus .REJECTED) )

return ” red ” ;

else i f ( s . equa l s ( Quest ionStatus .PART AGREED) )

return ” pink ” ;

390 } else i f ( propertyId . t oS t r i ng ( ) . conta in s (

” de l ivApprovat ionStatus ” ) ) {Item item = quest ionsTab le . getItem ( itemId ) ;

i f ( item . getItemProperty ( ” ques t i on ” ) != null ) {f ina l Question q = ( Question ) item

. getItemProperty ( ” ques t i on ” ) . getValue ( ) ;

i f ( q . ge tRe la t i on ( ) != null )

return null ;

}f ina l St r ing s = ( St r ing ) item . getItemProperty (

400 ” de l ivApprovat ionStatus ” ) . getValue ( ) ;

i f ( s == null )

return ” orange ” ;

else i f ( s . equa l s ( Quest ionStatus .TO SPECIFY) )

return ” orange ” ;

else i f ( s

. equa l s ( Quest ionStatus .YET TO ANALYZE) )

return ” ye l low ” ;

else i f ( s . equa l s ( Quest ionStatus .ACCEPTED) )

return ” green ” ;

410 else i f ( s . equa l s ( Quest ionStatus .REJECTED) )

return ” red ” ;

else i f ( s . equa l s ( Quest ionStatus .PART AGREED) )

return ” pink ” ;

428

Page 447: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

} else i f ( propertyId . t oS t r i ng ( ) . conta in s (

” f i n a l S t a t u s ” ) ) {Item item = quest ionsTab le . getItem ( itemId ) ;

S t r ing s = ( St r ing ) item . getItemProperty (

” f i n a l S t a t u s ” ) . getValue ( ) ;

i f ( s == null )

420 return ” orange ” ;

else i f ( s . equa l s ( Quest ionStatus .TO SPECIFY) )

return ” orange ” ;

else i f ( s

. equa l s ( Quest ionStatus .YET TO ANALYZE) )

return ” ye l low ” ;

else i f ( s . equa l s ( Quest ionStatus .ACCEPTED) )

return ” green ” ;

else i f ( s . equa l s ( Quest ionStatus .REJECTED) )

return ” red ” ;

430 else i f ( s . equa l s ( Quest ionStatus .PART AGREED) )

return ” pink ” ;

}return null ;

}}) ;

Link exportZip = new Link ( ”Export ECORE ( diagram graph ) ” ,

c t r l Q u e s t i o n n a i r e . exportEcoreDiag ( ) ) ;

Embedded embedded1 = new Embedded( ”” , c t r l Q u e s t i o n n a i r e

. exportPieQRefPackage ( ) ) ;

440 Embedded embedded2 = new Embedded( ”” , c t r l Q u e s t i o n n a i r e

. exportPieARefPackage ( ) ) ;

Embedded embedded3 = new Embedded( ”” , c t r l Q u e s t i o n n a i r e

. exportPieDRefPackage ( ) ) ;

p . addComponent ( ques t ionsTab le ) ;

Hor izonta lLayout images = new Horizonta lLayout ( ) ;

i f ( ! c t r l Q u e s t i o n n a i r e . getReferencePackage ( ) . getCanonicalName ( )

. conta in s ( de f in i t i onOfContex t ) ) {images . addComponent ( embedded3 ) ;

images . addComponent ( embedded1 ) ;

450 images . addComponent ( embedded2 ) ;

}p . addComponent ( images ) ;

p . setComponentAlignment ( images , Alignment .MIDDLE CENTER) ;

Panel p2 = new Panel ( ”” ) ;

p2 . s e tS i z eUnde f ined ( ) ;

p2 . addComponent ( exportZip ) ;

} else {p

460 . getWindow ( )

. showNot i f i c a t i on (

”No datas ” ,

”<br/>There aren ’ t any que s t i on s f o r t h i s p r o j e c t . ”

+ ”<br/><br/>You can add a new ques t i on by c l i c k i n g the button . ” ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}quest ionGridL . r eques tRepa intAl l ( ) ;

}

429

Page 448: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

470 private void r e f r e s h Q u e s t i o n L i s t ( ) {i f ( quest ionGridL != null && quest ionsTable != null

&& c t r l Q u e s t i o n n a i r e != null ) {List<AnswerSet> datas = c t r l Q u e s t i o n n a i r e . getListDataAnswer ( ) ;

i f ( datas . s i z e ( ) > 0) {i f ( quest ionsDataSource != null

&& quest ionsDataSource . get I temIds ( ) != null ) {for ( AnswerSet d : quest ionsDataSource . get I temIds ( ) ) {

c t r l Q u e s t i o n n a i r e . r e f r e s h ( quest ionsDataSource

. getItem (d) . getBean ( ) ) ;

480 }}Object [ ] v i s ib leColumns = quest ionsTab le . getVis ib leColumns ( ) ;

ques t ionsTab le . setContainerDataSource ( quest ionsDataSource ) ;

ques t ionsTab le . setVis ib leColumns ( v i s ib leColumns ) ;

}quest ionsTab le . r eques tRepa intAl l ( ) ;

quest ionGridL . r eques tRepa intAl l ( ) ;

}}

490public void q u e s t i o n D e t a i l s (boolean on lyHi s tory ) {

c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

f ina l AnswerSet qst = c t r l Q u e s t i o n n a i r e . getReferenceAnswset ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( qstEvidMap ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( qstDtlAnswering ) ;

S t r ing t i t l e = ” Question Id : ” + qst . getQuest ion ( ) . getQuest ionId ( ) ;

t i t l e = ” Question answering ” ;

i f ( on lyHi s tory )

t i t l e = ” History ” ;

500 qstDtlAnswering = new Window( t i t l e ) ;

ru lesExclTxtArea = new Vert i ca lLayout ( ) ;

rulesMultTxtArea = new Vert i ca lLayout ( ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) qstDtlAnswering . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . setWidth (870 , S i z e a b l e . UNITS PIXELS) ;

f ina l AnswerSet re sponse = qst ;

i f ( ! on lyHi s tory ) {p . addComponent (new Label ( qs t . getQuest ion ( ) . getQuest ion ( ) ) ) ;

510 i f ( re sponse . getQuest ion ( ) . g e tRe la t i on ( ) != null ) {Mclass cs = response . getQuest ion ( ) . g e tRe la t i on ( )

. ge tMf i e ldSource ( ) . getOwnerClass ( ) ;

Mclass ct = response . getQuest ion ( ) . g e tRe la t i on ( )

. ge tMf i e ldSource ( ) . getTypeClass ( ) ;

L i s t<Evidence> l = null ;

S t r ing ev idencesSource = ” Evidences f o r ” + cs . getName ( )

+ ” are : ” ;

l = c t r l Q u e s t i o n n a i r e . getEvidencesForMClass ( cs ) ;

i f ( l == null | | l . s i z e ( ) == 0) {520 ev idencesSource = ”There aren ’ t no ev idence s f o r ”

+ cs . getName ( ) ;

} else {boolean f i r s t = true ;

for ( Evidence a : l ) {

430

Page 449: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

ev idencesSource += ( ! f i r s t ?” , ” : ”” ) +

a . getAlternat iveAnswer ( ) . getAnswer ( ) ;

f i r s t = fa l se ;

}}St r ing ev idencesTarget = ” Evidences f o r ” + ct . getName ( )

530 + ” are : ” ;

l = c t r l Q u e s t i o n n a i r e . getEvidencesForMClass ( c t ) ;

i f ( l == null | | l . s i z e ( ) == 0) {ev idencesTarget = ”There aren ’ t no ev idence s f o r ”

+ ct . getName ( ) ;

} else {boolean f i r s t = true ;

for ( Evidence a : l ) {ev idencesTarget += ( ! f i r s t ?” , ” : ”” ) +

a . getAlternat iveAnswer ( ) . getAnswer ( ) ;

f i r s t = fa l se ;

540 }}p . addComponent (new Label ( ”” ) ) ;

p . addComponent (new Label ( ev idencesSource ) ) ;

p . addComponent (new Label ( ev idencesTarget ) ) ;

p . addComponent (new Label ( ”” ) ) ;

}i f ( re sponse . getOpenAnswer ( ) == null )

re sponse . setOpenAnswer ( ”” ) ;

BeanItem<AnswerSet> a l t I t em = new BeanItem<AnswerSet>( r e sponse ) ;

550 f ina l Form modifyForm = new Form ( ) {} ;

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm . setFormFieldFactory (new AnswerSetFie ldFactory ( response ,

true ) ) ;

modifyForm . setItemDataSource ( a l t I t em ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays

. a s L i s t (new St r ing [ ] { ”openAnswer” }) ) ;

i f ( re sponse . getQuest ion ( ) . getOpenQuestion ( ) != null

560 && response . getQuest ion ( ) . getOpenQuestion ( )

. equa l s IgnoreCase ( ” yes ” ) ) {p . addComponent ( modifyForm ) ;

}f ina l LinkedHashMap<Integer , F i l l ingBean> f i l l i n g s = new

LinkedHashMap<Integer , F i l l ingBean >() ;

i f ( re sponse . getAnswsetAnsws ( ) != null

&& response . getAnswsetAnsws ( ) . s i z e ( ) > 0) {f ina l TreeTable ansTable = new TreeTable ( ) ;

ansTable . setWidth (98 , S i z e a b l e .UNITS PERCENTAGE) ;

ansTable . s e t S e l e c t a b l e ( true ) ;

570 ansTable . setImmediate ( true ) ;

for ( Evidence a : r e sponse . getAnswsetAnsws ( ) ) {f ina l Fi l l i ngBean f = new Fi l l i ngBean ( a ) ;

f i l l i n g s . put ( f . getAnswerId ( ) , f ) ;

CheckBox c = f . getYesno ( ) ;

c . setEnabled ( c t r l Q u e s t i o n n a i r e . checkRu le sSta t i c ( f ) ) ;

c . addLis tener (new Property . ValueChangeListener ( ) {@Override

431

Page 450: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void valueChange ( ValueChangeEvent event ) {c t r l Q u e s t i o n n a i r e . checkRulesDynamic ( f i l l i n g s , f

580 . getAnswerId ( ) ) ;

c t r l Q u e s t i o n n a i r e . showRulesMultep l i c i ty ( f i l l i n g s , f

. getAnswerId ( ) ) ;

}}) ;

c . setImmediate ( true ) ;

Button b = f . getRules ( ) ;

b . addLis tener (new C l i c k L i s t e n e r ( ) {private stat ic f ina l long se r ia lVer s ionUID = 7318198692625664774L ;

590 @Override

public void buttonCl ick ( ClickEvent event ) {int x1 = f . getAnswsetAnsw ( ) . getAlternat iveAnswer ( )

. ge tRuleExc lus ionsSource ( ) . s i z e ( ) ;

int x2 = f . getAnswsetAnsw ( ) . getAlternat iveAnswer ( )

. getRuleExc lus ionsTarget ( ) . s i z e ( ) ;

i f ( x1 + x2 > 0)

c t r l Q u e s t i o n n a i r e . showRules ( f i l l i n g s , f

. getAnswerId ( ) ) ;

else

600 a p p l i c a t i o n

. showNot i f i c a t i on ( ” This re sponse i s not a f f e c t e d by any

e x c l u s i o n r u l e s ” ) ;

}}) ;

}BeanItemContainer<Fi l l ingBean> ansDataSource = new

BeanItemContainer<Fi l l ingBean >(

f i l l i n g s . va lue s ( ) ) ;

ansTable . setContainerDataSource ( ansDataSource ) ;

int f i r s t l e v e l = 0 ;

610 for ( Evidence a : r e sponse . getAnswsetAnsws ( ) ) {f ina l Fi l l i ngBean tmpP = f i l l i n g s . get ( a

. getAlternat iveAnswer ( ) . getAnswerId ( ) ) ;

ansTable . setChi ldrenAl lowed (tmpP , fa l se ) ;

i f ( a . getSonAnswsetAnsws ( ) != null

&& a . getSonAnswsetAnsws ( ) . s i z e ( ) > 0) {ansTable . setChi ldrenAl lowed (tmpP , true ) ;

f i r s t l e v e l ++;

for ( Evidence b : a . getSonAnswsetAnsws ( ) ) {Fi l l i ngBean tmpC = f i l l i n g s . get (b

620 . getAlternat iveAnswer ( ) . getAnswerId ( ) ) ;

ansTable . se tParent (tmpC, tmpP) ;

ansTable . setChi ldrenAl lowed (tmpC, fa l se ) ;

System . out . p r i n t l n (tmpP . getAnswer ( ) + ” <− ”

+ tmpC . getAnswer ( ) ) ;

tmpP . addChild (tmpC) ;

f i l l i n g s . remove (b . getAlternat iveAnswer ( )

. getAnswerId ( ) ) ;

}tmpP . i n i t C h i l d r e n ( ) ;

630 tmpP . getYesno ( ) . addLis tener (

new Property . ValueChangeListener ( ) {

432

Page 451: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@Override

public void valueChange (

ValueChangeEvent event ) {i f ( ( Boolean ) (tmpP . getYesno ( )

. getValue ( ) ) == true )

ansTable . setChi ldrenAl lowed (tmpP ,

true ) ;

else

640 ansTable . setChi ldrenAl lowed (tmpP ,

fa l se ) ;

}}) ;

} else {i f ( a . getFatherAnswsetAnsws ( ) == null ) {

System . out . p r i n t l n (tmpP . getAnswer ( )

+ ” non ha f i g l i ” ) ;

f i r s t l e v e l ++;

}650 }

}i f ( ! c t r l Q u e s t i o n n a i r e . getReferencePackage ( ) . getCanonicalName ( )

. conta in s ( de f in i t i onOfContex t ) ) {ansTable . setVis ib leColumns (new Object [ ] { ”answer” ,

” yesno ” , ” approvat ion ” , ” r u l e s ” }) ;

ansTable . setColumnHeaders (new St r ing [ ] { ”Answer” , ”Y/N” ,

” Status ” , ” Rules ” }) ;

} else {ansTable . setVis ib leColumns (new Object [ ] { ”answer” ,

660 ” yesno ” , ” r u l e s ” }) ;

ansTable . setColumnHeaders (new St r ing [ ] { ”Answer” , ”Y/N” ,

” Rules ” }) ;

}ansTable . set ItemCapt ionPropertyId ( ”answsetAnswId” ) ;

ansTable . setColumnReorderingAllowed ( fa l se ) ;

ansTable . setColumnCollapsingAllowed ( fa l se ) ;

int tmp = 10 ;

ansTable . setPageLength (tmp) ;

670 p . addComponent ( ansTable ) ;

p . setComponentAlignment ( ansTable , ” c en te r ” ) ;

}Button apply = new Button ( ”Save and c l o s e ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

modifyForm . commit ( ) ;

ArrayList<Evidence> r e s p o n s e l = new ArrayList<Evidence >() ;

for ( F i l l i ngBean f : f i l l i n g s . va lue s ( ) ) {r e s p o n s e l . add ( f . getAnswsetAnswCommitted ( ) ) ;

680 }showConfirmationComment ( r e sponse l , r e sponse ) ;

}}) ;

Button c l o s e = new Button ( ” Close without sav ing ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

433

Page 452: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

qstDtlAnswering ) ;

}690 }) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent (new Label ( ” ” ,

Label .CONTENT PREFORMATTED) ) ;

btnLayout . addComponent ( c l o s e ) ;

p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

Label multiplWarning = new Label (

” Required number o f a l t e r n a t i v e s : ”

700 + c t r l Q u e s t i o n n a i r e . showMultep l i c i ty ( ) ) ;

p . addComponent ( multiplWarning ) ;

p . addComponent (new Label (

” Rules ( c l i c k the button ’−>’ near chosen a l t e r n a t i v e ) ” ) ) ;

p . addComponent ( rulesExclTxtArea ) ;

p . addComponent ( rulesMultTxtArea ) ;

}

f ina l List<AnswsetHistory> h i s t o r y = response . ge tAnswse tHi s to r i e s ( ) ;

i f ( h i s t o r y != null && h i s t o r y . s i z e ( ) > 0) {710 C o l l e c t i o n s . s o r t ( h i s to ry , new Comparator<AnswsetHistory >() {

@Override

public int compare ( AnswsetHistory o1 , AnswsetHistory o2 ) {i f ( o1 . getModtime ( ) . a f t e r ( o2 . getModtime ( ) ) )

return −1;

else i f ( o1 . getModtime ( ) . b e f o r e ( o2 . getModtime ( ) ) )

return 1 ;

return 0 ;

}}) ;

720 p . addComponent (new Label ( ” Status changes h i s t o r y ” ) ) ;

f ina l Table h i s tTab le = new Table ( ) {@Override

protected St r ing formatPropertyValue ( Object rowId ,

Object co l Id , Property property ) {Object v = property . getValue ( ) ;

i f ( v instanceof Date ) {Date dateValue = ( Date ) v ;

SimpleDateFormat df = new SimpleDateFormat (

”d MMM yyyy HH:mm: s s ” ) ;

730 return df . format ( dateValue ) ;

}return super . formatPropertyValue ( rowId , co l Id , property ) ;

}} ;

h i s tTab l e . setWidth (98 , S i z e a b l e .UNITS PERCENTAGE) ;

h i s tTab l e . s e t S e l e c t a b l e ( fa l se ) ;

h i s tTab l e . setImmediate ( fa l se ) ;

BeanItemContainer<AnswsetHistory> ansDataSource = new

BeanItemContainer<AnswsetHistory >(

h i s t o r y ) ;

740 h i s tTab l e . setContainerDataSource ( ansDataSource ) ;

h i s tTab l e . se tVis ib leColumns (new Object [ ] { ”modtime” , ” user ” ,

434

Page 453: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

” r o l e ” , ” ac t i on ” , ”comment” }) ;

h i s tTab l e . setColumnHeaders (new St r ing [ ] { ”Date” , ”User” , ”Role” ,

” Action ” , ”Comment” }) ;

h i s tTab l e . addGeneratedColumn ( ” ac t i on ” , new ColumnGenerator ( ) {public Component g e n e r a t e Ce l l ( Table source , Object itemId ,

Object columnId ) {750 St r ing html = ( ( AnswsetHistory ) itemId ) . getAct ion ( ) ;

html = html . r e p l a c e ( ”\n” , ”<br/>” ) ;

Label label = new Label ( html , Label .CONTENT XHTML) ;

label . setWidth ( ”15em” ) ;

return label ;

}}) ;

h i s tTab l e . addGeneratedColumn ( ”comment” , new ColumnGenerator ( ) {public Component g e n e r a t e Ce l l ( Table source , Object itemId ,

Object columnId ) {760 St r ing html = ( ( AnswsetHistory ) itemId ) . getComment ( ) ;

html = html . r e p l a c e ( ”\n” , ”<br/>” ) ;

Label label = new Label ( html , Label .CONTENT XHTML) ;

label . setWidth ( ”15em” ) ;

return label ;

}}) ;

h i s tTab l e . setColumnReorderingAllowed ( fa l se ) ;

h i s tTab l e . setColumnCollapsingAllowed ( fa l se ) ;

770 int x = 3 ;

i f ( h i s t o r y . s i z e ( ) < x )

x = h i s t o r y . s i z e ( ) ;

h i s tTab l e . setPageLength ( x ) ;

p . addComponent ( h i s tTab le ) ;

} else {p . addComponent (new Label ( ”No h i s t o r y a v a i l a b l e ” ) ) ;

}qstDtlAnswering . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( qstDtlAnswering ) ;

780 }

protected void showConfirmationComment (

f ina l ArrayList<Evidence> r e sponse l , f ina l AnswerSet re sponse ) {c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( qstDtlAnswering ) ;

qstDtlAnswering = new Window( ”Comment your changes ” ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) qstDtlAnswering . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

790 p . s e tS i z eUnde f ined ( ) ;

f ina l AnswsetHistory h i s t = new AnswsetHistory ( ) ;

h i s t . setComment ( ”” ) ;

h i s t . s e tRo le ( ” Supp l i e r ” ) ;

BeanItem<AnswsetHistory> a l t I t em = new BeanItem<AnswsetHistory >( h i s t ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

435

Page 454: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

modifyForm . setFormFieldFactory (new AnswerHistoryFie ldFactory ( h i s t ) ) ;

800 modifyForm . setItemDataSource ( a l t I t em ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays

. a s L i s t (new St r ing [ ] { ”comment” }) ) ;

p

. addComponent (new Label (

” Please exp la in the reason o f answer ’ s change” ) ) ;

p . addComponent ( modifyForm ) ;

Button apply = new Button ( ”Save and c l o s e ” , new Button . C l i c k L i s t e n e r ( ) {810 public void buttonCl ick ( ClickEvent event ) {

modifyForm . commit ( ) ;

c t r l Q u e s t i o n n a i r e . saveAnswerSet ( r e sponse l , response , h i s t ) ;

i f ( qstDtlAnswering != null )

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

qstDtlAnswering ) ;

}}) ;

Button c l o s e = new Button ( ” Close without sav ing ” ,

new Button . C l i c k L i s t e n e r ( ) {820 public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

qstDtlAnswering ) ;

}}) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

btnLayout . addComponent ( c l o s e ) ;

830 p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

qstDtlAnswering . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( qstDtlAnswering ) ;

}

protected void showConfirmationCommentDeliverable ( f ina l Evidence a ,

f ina l ArrayList<Del iverab leEvidence> dats ) {840 c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( qstDtlAnswering ) ;

qstDtlAnswering = new Window( ”Comment your changes ” ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) qstDtlAnswering . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

f ina l Del ive rab l eContentHi s to ry h i s t = new Del ive rab l eContentHi s to ry ( ) ;

h i s t . setComment ( ”” ) ;

850 h i s t . s e tRo le ( ” Supp l i e r ” ) ;

BeanItem<Del iverab leContentHis tory> a l t I t em = new

BeanItem<Del iverab leContentHis tory >(

h i s t ) ;

f ina l Form modifyForm = new Form ( ) ;

436

Page 455: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm

. setFormFieldFactory (new Del ivContentHis toryFie ldFactory ( h i s t ) ) ;

modifyForm . setItemDataSource ( a l t I t em ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays

860 . a s L i s t (new St r ing [ ] { ”comment” }) ) ;

p . addComponent (new Label ( ” Please exp la in the ”

+ ” reason o f answer ’ s change” ) ) ;

p . addComponent ( modifyForm ) ;

Button apply = new Button ( ”Save and c l o s e ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

modifyForm . commit ( ) ;

c t r l Q u e s t i o n n a i r e . saveDel iverablesMapping ( a , dats , h i s t ) ;

i f ( qstDtlAnswering != null )

870 a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

qstDtlAnswering ) ;

}}) ;

Button c l o s e = new Button ( ” Close without sav ing ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

qstDtlAnswering ) ;

}880 }) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

btnLayout . addComponent ( c l o s e ) ;

p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

qstDtlAnswering . c en t e r ( ) ;

890 a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( qstDtlAnswering ) ;

}

public void showExclRules (HashMap<Str ing , L i s t<ExclusionBean>> r i s ,

LinkedList<Str ing> keys ) {rulesExclTxtArea . removeAllComponents ( ) ;

L i s t<ExclusionBean> datas2 = new LinkedList<ExclusionBean >() ;

S t r ing t i t l e = ”” ;

i f ( keys != null && keys . s i z e ( ) > 0) {900 for ( S t r ing kk : keys )

i f ( r i s . get ( kk ) != null && r i s . get ( kk ) . s i z e ( ) > 0) {St r ing p = kk ;

i f (p . equa l s ( ” excluded ” ) | | p . equa l s ( ” may excluded ” ) )

p = ” I s d i s ab l ed by : ” ;

else i f (p . equa l s ( ” excluded2 ” ) )

p = ” Rules : ” ;

else i f (p . equa l s ( ” exc ludes ” ) )

p = ” Disab le f o l l o w i n g a l t e r n a t i v e s : ” ;

else i f (p . equa l s ( ”mult” ) )

437

Page 456: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

910 p = ”Change m u l t e p l i c i t y : ” ;

datas2 . addAll ( r i s . get ( kk ) ) ;

}} else

t i t l e = ”There are no r u l e s ” ;

i f ( datas2 . s i z e ( ) == 0)

t i t l e = ”There are no r u l e s ” ;

rulesExclTxtArea . addComponent (new Label ( t i t l e ) ) ;

i f ( datas2 . s i z e ( ) > 0) {Table exc lTable = new Table ( ) ;

920 exc lTable . s e t S e l e c t a b l e ( true ) ;

exc lTable . setImmediate ( true ) ;

BeanItemContainer<ExclusionBean> exclDataSource = new

BeanItemContainer<ExclusionBean >(

datas2 ) ;

exc lTable . setContainerDataSource ( exc lDataSource ) ;

exc lTable . setVis ib leColumns (new Object [ ] { ” d i r e c t i o n ” , ” t r i g g e r ” ,

”answer” , ” ques t i on ” }) ;

exc lTable . setColumnHeaders (new St r ing [ ] { ” D i r e c t i on ” , ” Tr igger ” ,

”Answer” , ” Question ” }) ;

exc lTable . set ItemCapt ionPropertyId ( ” ques t i on Id ” ) ;

930 exc lTable . setColumnReorderingAllowed ( fa l se ) ;

exc lTable . setColumnCollapsingAllowed ( fa l se ) ;

int x = 3 ;

i f ( datas2 . s i z e ( ) < x )

x = datas2 . s i z e ( ) ;

exc lTable . setPageLength ( x ) ;

rulesExclTxtArea . addComponent ( exc lTable ) ;

}}

940 public void showMultRules (HashMap<Str ing , L i s t<Str ing>> r i s ,

LinkedList<Str ing> keys ) {rulesMultTxtArea . removeAllComponents ( ) ;

Tree t r e e = new Tree ( ) ;

i f ( keys != null && keys . s i z e ( ) > 0) {for ( S t r ing kk : keys )

i f ( r i s . get ( kk ) . s i z e ( ) > 0) {St r ing p = kk ;

i f (p . equa l s ( ”ok” ) )

p = ” Passed ” ;

950 else i f (p . equa l s ( ” e r r o r ” ) )

p = ” Errors ” ;

t r e e . addItem (p) ;

for ( S t r ing k : r i s . get ( kk ) ) {t r e e . addItem ( k ) ;

t r e e . se tParent (k , p) ;

t r e e . setChi ldrenAl lowed (k , fa l se ) ;

}t r e e . expandItemsRecurs ive ly (p) ;

}960 } else

t r e e . addItem ( ”There are no r u l e s ” ) ;

rulesMultTxtArea . addComponent ( t r e e ) ;

}

438

Page 457: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void ques t i onDeta i l sEv idence (boolean onlyHistory ,

f ina l Evidence a2 ) {c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

f ina l AnswerSet qst = c t r l Q u e s t i o n n a i r e . getReferenceAnswset ( ) ;

f ina l List<Del ive rab l e> d e l i v s = c t r l Q u e s t i o n n a i r e

970 . g e t D e l i v e r a b l e s L i s t ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( qstEvidMap ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( qstDtlAnswering ) ;

S t r ing t i t l e = ” Question Id : ” + qst . getQuest ion ( ) . getQuest ionId ( ) ;

t i t l e = ” Evidence to d e l i v e r a b l e s mapping” ;

qstEvidMap = new Window( t i t l e ) ;

qstEvidMap . setWidth (870 , S i z e a b l e . UNITS PIXELS) ;

qstEvidMap . se tHe ight (600 , S i z e a b l e . UNITS PIXELS) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) qstEvidMap . getContent ( ) ;

p . setMargin ( true ) ;

980 p . se tSpac ing ( true ) ;

f ina l AnswerSet re sponse = qst ;

i f ( re sponse . getAnswsetAnsws ( ) != null

&& response . getAnswsetAnsws ( ) . s i z e ( ) > 0) {p . addComponent (new Label ( qs t . getQuest ion ( ) . getQuest ion ( ) ) ) ;

Panel pane l s = new Panel ( ” This i s a l i g h t Panel ” ) ;

pane l s . setCapt ion ( null ) ;

pane l s . setStyleName ( Panel . STYLE LIGHT) ;

ComponentContainer ansTableWrapWrap = pane l s . getContent ( ) ;

pane l s . s e t S i z e F u l l ( ) ;

990 p . addComponent ( pane l s ) ;

for ( f ina l Evidence a : r e sponse . getAnswsetAnsws ( ) )

i f ( a . getResponse ( ) . equa l s IgnoreCase ( ” yes ” ) ) {f ina l Vert i ca lLayout tv = new Vert i ca lLayout ( ) ;

f ina l Panel panel = new Panel ( ” This i s a l i g h t Panel ” ) ;

panel . setCapt ion ( null ) ;

panel . setStyleName ( Panel . STYLE LIGHT) ;

panel . s e tHe ight (1 , S i z e a b l e . UNITS PIXELS) ;

panel . setWidth (99 , S i z e a b l e .UNITS PERCENTAGE) ;

panel . s e t S c r o l l a b l e ( true ) ;

1000 ComponentContainer ansTableWrap = panel . getContent ( ) ;

f ina l Horizonta lLayout tv1 = new Horizonta lLayout ( ) ;

f ina l Table t = new Table ( ) ;

Button b1 = new Button ( a . getAlternat iveAnswer ( ) . getAnswer ( ) ) ;

b1 . setWidth (99 , S i z e a b l e .UNITS PERCENTAGE) ;

b1 . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {i f ( panel . getHeight ( ) < 10) {

panel . s e tHe ight (250 , S i z e a b l e . UNITS PIXELS) ;

1010 panel . s e t S c r o l l a b l e ( fa l se ) ;

} else {panel . s e tHe ight (0 , S i z e a b l e . UNITS PIXELS) ;

panel . s e t S c r o l l a b l e ( fa l se ) ;

}}

}) ;

Hor izonta lLayout l = new Horizonta lLayout ( ) ;

l . setWidth (99 , S i z e a b l e .UNITS PERCENTAGE) ;

l . addComponent ( b1 ) ;

1020 l . setExpandRatio ( b1 , 1 . 0 f ) ;

439

Page 458: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

l . addComponent (new Label ( ” Status : ”

+ a . getApprovat ionDel ivStatus ( ) ) ) ;

ansTableWrap . addComponent ( tv ) ;

ansTableWrapWrap . addComponent ( l ) ;

ansTableWrapWrap . addComponent ( panel ) ;

i f ( ! on lyHi s tory ) {{

f ina l HashMap<Del iverab leEvidence , EvidenceMapBean> f i l l i n g s = new

HashMap<Del iverab leEvidence , EvidenceMapBean>() ;

ArrayList<EvidenceMapBean> datas = new ArrayList<EvidenceMapBean>() ;

1030 for ( D e l i v e r a b l e d : d e l i v s ) {Del ive rab l eEv idence de = c t r l Q u e s t i o n n a i r e

. g e tDe l i v e rab l eEv idence (a , d) ;

f ina l EvidenceMapBean f = new EvidenceMapBean (

de ) ;

f i l l i n g s . put ( f . getDelEvid ( ) , f ) ;

datas . add ( f ) ;

f . getYesno ( ) . setImmediate ( true ) ;

}BeanItemContainer<EvidenceMapBean> ds = new

BeanItemContainer<EvidenceMapBean>(

1040 datas ) ;

t . setContainerDataSource ( ds ) ;

t . se tVis ib leColumns (new Object [ ] { ” yesno ” ,

” d e l i v e r a b l e ” , ” addIn foF ie ld ” , ”comment” ,

” agreementStatus ” }) ;

t . setColumnHeaders (new St r ing [ ] { ” Inc luded ” ,

” D e l i v e r a b l e ” , ”Add . In f o . ” , ”Comment” ,

”Agreed” }) ;

t . setColumnReorderingAllowed ( fa l se ) ;

t . setColumnCollapsingAllowed ( fa l se ) ;

1050 int x = datas . s i z e ( ) ;

t . setPageLength ( x < 6 ? x : 6) ;

t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

t . s e t M u l t i S e l e c t ( fa l se ) ;

t . s e t S i z e F u l l ( ) ;

Button apply = new Button ( ”Save” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

ArrayList<Del iverab leEvidence> dats = new

ArrayList<Del iverab leEvidence >() ;

for ( De l ive rab l eEv idence de : f i l l i n g s

1060 . keySet ( ) ) {EvidenceMapBean d = f i l l i n g s

. get ( de ) ;

de . s e t Inc luded ( ( Boolean ) d

. getYesno ( ) . getValue ( ) ) ;

de . s e t A d d i t i o n a l I n f o (d

. getAddInfoFie ld ( )

. getValue ( ) . t oS t r i ng ( ) ) ;

dats . add ( de ) ;

}1070 showConfirmationCommentDeliverable (

a , dats ) ;

}}) ;

440

Page 459: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

Button d i s ca rd = new Button ( ” Discard ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

ques t i onDeta i l sEv idence ( false , a2 ) ;

}}) ;

1080 tv1 . setWidth (99 , S i z e a b l e .UNITS PERCENTAGE) ;

tv1 . addComponent ( apply ) ;

tv1 . setComponentAlignment ( apply ,

Alignment .MIDDLE CENTER) ;

tv1 . addComponent ( d i s ca rd ) ;

tv1 . setComponentAlignment ( d i scard ,

Alignment .MIDDLE CENTER) ;

}i f ( a2 != null

&& a . getAnswsetAnswId ( ) == a2

1090 . getAnswsetAnswId ( ) )

panel . s e tHe ight (250 , S i z e a b l e . UNITS PIXELS) ;

tv . addComponent ( t ) ;

tv . addComponent ( tv1 ) ;

}f ina l List<Del iverab leContentHis tory> h i s t o r y = a

. getAnswsetAnswDel ivHistor ies ( ) ;

i f ( h i s t o r y != null && h i s t o r y . s i z e ( ) > 0) {C o l l e c t i o n s

. s o r t (

1100 h i s to ry ,

new Comparator<Del iverab leContentHis tory >() {@Override

public int compare (

De l ive rab l eContentHi s to ry o1 ,

De l ive rab l eContentHi s to ry o2 ) {i f ( o1 . getModtime ( ) . a f t e r (

o2 . getModtime ( ) ) )

return −1;

else i f ( o1

1110 . getModtime ( )

. b e f o r e ( o2 . getModtime ( ) ) )

return 1 ;

return 0 ;

}}) ;

f ina l Table h i s tTab l e = new Table ( ) {@Override

protected St r ing formatPropertyValue ( Object rowId ,

Object co l Id , Property property ) {1120 Object v = property . getValue ( ) ;

i f ( v instanceof Date ) {Date dateValue = ( Date ) v ;

SimpleDateFormat df = new SimpleDateFormat (

”d MMM yyyy HH:mm: s s ” ) ;

return df . format ( dateValue ) ;

}return super . formatPropertyValue ( rowId , co l Id ,

property ) ;

}

441

Page 460: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

1130 } ;

h i s tTab l e . setWidth (98 , S i z e a b l e .UNITS PERCENTAGE) ;

h i s tTab l e . s e t S e l e c t a b l e ( fa l se ) ;

h i s tTab l e . setImmediate ( fa l se ) ;

BeanItemContainer<Del iverab leContentHis tory> ansDataSource = new

BeanItemContainer<Del iverab leContentHis tory >(

h i s t o r y ) ;

h i s tTab l e . setContainerDataSource ( ansDataSource ) ;

h i s tTab l e . se tVis ib leColumns (new Object [ ] { ”modtime” ,

” user ” , ” r o l e ” , ” ac t i on ” , ”comment” }) ;

1140 h i s tTab l e . setColumnHeaders (new St r ing [ ] { ”Date” ,

”User” , ”Role” , ” Action ” , ”Comment” }) ;

h i s tTab l e . addGeneratedColumn ( ” ac t i on ” ,

new ColumnGenerator ( ) {public Component g e n e r a t e C e l l ( Table source ,

Object itemId , Object columnId ) {St r ing html = ( ( De l ive rab l eContentHi s to ry ) itemId )

. getAct ion ( ) ;

html = html . r e p l a c e ( ”\n” , ”<br/>” ) ;

1150 Label label = new Label ( html ,

Label .CONTENT XHTML) ;

label . setWidth ( ”15em” ) ;

return label ;

}}) ;

h i s tTab l e . addGeneratedColumn ( ”comment” ,

new ColumnGenerator ( ) {public Component g e n e r a t e C e l l ( Table source ,

Object itemId , Object columnId ) {1160 St r ing html = ( ( De l ive rab l eContentHi s to ry ) itemId )

. getComment ( ) ;

html = html . r e p l a c e ( ”\n” , ”<br/>” ) ;

Label label = new Label ( html ,

Label .CONTENT XHTML) ;

label . setWidth ( ”15em” ) ;

return label ;

}}) ;

h i s tTab l e . setColumnReorderingAllowed ( fa l se ) ;

1170 h i s tTab l e . setColumnCollapsingAllowed ( fa l se ) ;

int x = 3 ;

i f ( h i s t o r y . s i z e ( ) < x )

x = h i s t o r y . s i z e ( ) ;

h i s tTab l e . setPageLength ( x ) ;

tv . addComponent (new Label ( ”” ,

Label .CONTENT PREFORMATTED) ) ;

tv . addComponent (new Label ( ” Status changes h i s t o r y ” ) ) ;

tv . addComponent ( h i s tTab le ) ;

} else {1180 tv . addComponent (new Label ( ”” ,

Label .CONTENT PREFORMATTED) ) ;

tv . addComponent (new Label ( ”No h i s t o r y a v a i l a b l e ” ) ) ;

}i f ( on lyHi s tory ) {

442

Page 461: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

panel . s e tHe ight (250 , S i z e a b l e . UNITS PIXELS) ;

}}

}qstEvidMap . c en t e r ( ) ;

1190 a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( qstEvidMap ) ;

}

public class HistoryBean {Date modtime ;

S t r ing user ;

PopupView ac t i on ;

PopupView comment ;

public HistoryBean ( AnswsetHistory h) {1200 modtime = h . getModtime ( ) ;

user = h . getUser ( ) . getName ( ) ;

a c t i on = new PopupView ( ”view” , new Label (h . getAct ion ( ) ) ) ;

comment = new PopupView ( ”view” , new Label (h . getComment ( ) ) ) ;

}

public Date getModtime ( ) {return modtime ;

}

1210 public St r ing getUser ( ) {return user ;

}

public PopupView getAct ion ( ) {return ac t i on ;

}

public PopupView getComment ( ) {return comment ;

1220 }}

public void q u e s t i o n D e t a i l s H i s t o r y ( ) {q u e s t i o n D e t a i l s ( true ) ;

}

public void que s t i onDeta i l sEv idenceH i s to ry ( ) {ques t i onDeta i l sEv idence ( true , null ) ;

}1230

}

D.6.8 Classe ModelUI.java

package i t . uniroma2 . norge . web ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . c o n t r o l l e r . UmlModelCtrl ;

443

Page 462: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import i t . uniroma2 . norge . model . jpa . Model ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . ModelFie ldFactory ;

import java . u t i l . Arrays ;

import java . u t i l . L i s t ;

10import com . vaadin . data . u t i l . BeanItem ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . t e rmina l . S i z e a b l e ;

import com . vaadin . u i . Alignment ;

import com . vaadin . u i . Button ;

import com . vaadin . u i . Form ;

import com . vaadin . u i . FormLayout ;

import com . vaadin . u i . GridLayout ;

import com . vaadin . u i . Hor izonta lLayout ;

20 import com . vaadin . u i . Label ;

import com . vaadin . u i . Panel ;

import com . vaadin . u i . P r o g r e s s I n d i c a t o r ;

import com . vaadin . u i . Table ;

import com . vaadin . u i . Upload ;

import com . vaadin . u i . Vert i ca lLayout ;

import com . vaadin . u i . Button . Cl ickEvent ;

import com . vaadin . u i . Upload . Fai ledEvent ;

import com . vaadin . u i . Upload . FinishedEvent ;

import com . vaadin . u i . Upload . StartedEvent ;

30 import com . vaadin . u i . Upload . SucceededEvent ;

import com . vaadin . u i . Window . N o t i f i c a t i o n ;

public class ModelUI {

private TesiwebAppl icat ion a p p l i c a t i o n ;

private UmlModelCtrl ctrlUmlModel ;

private Vert i ca lLayout body ;

40private GridLayout modelGridL ;

private BeanItemContainer<Model> modelsDataSource ;

public Table modelsTable ;

public ModelUI ( Tes iwebAppl icat ion appl ) {this . a p p l i c a t i o n = appl ;

ctrlUmlModel = a p p l i c a t i o n . getCtrlUmlModel ( ) ;

50 body = a p p l i c a t i o n . getBody ( ) ;

}

public void umlList ( ) {ctrlUmlModel = a p p l i c a t i o n . getCtrlUmlModel ( ) ;

a p p l i c a t i o n . setArea ( ”” ) ;

body . removeAllComponents ( ) ;

Panel p = new Panel ( ”” ) ;

p . setWidth (95 , S i z e a b l e .UNITS PERCENTAGE) ;

modelGridL = new GridLayout (2 , 1) ;

60 modelGridL . se tSpac ing ( true ) ;

444

Page 463: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

modelGridL . setMargin ( true ) ;

modelGridL . s e t S i z e F u l l ( ) ;

modelGridL . addComponent (p , 0 , 0) ;

body . addComponent ( modelGridL ) ;

body . setComponentAlignment ( modelGridL , Alignment .TOP LEFT) ;

modelsTable = new Table ( ) ;

modelsTable . s e t S e l e c t a b l e ( true ) ;

modelsTable . setImmediate ( true ) ;

70 modelsTable . addLis tener ( a p p l i c a t i o n . getCtrlUmlModel ( ) ) ;

L i s t<Model> datas = ctrlUmlModel . getL is tData ( ) ;

i f ( datas . s i z e ( ) > 0) {modelsDataSource = new BeanItemContainer<Model>(datas ) ;

modelsTable . setContainerDataSource ( modelsDataSource ) ;

modelsTable . setVis ib leColumns (new Object [ ] { ” d e s c r i p t i o n ” }) ;

modelsTable . setColumnHeaders (new St r ing [ ] { ” Desc r ip t i on ” }) ;

modelsTable . setRowHeaderMode ( Table .ROW HEADER MODE PROPERTY) ;

modelsTable . se t I temIconPropertyId ( ”modelId” ) ;

modelsTable . set ItemCapt ionPropertyId ( ”modelId” ) ;

80 modelsTable . setColumnReorderingAllowed ( true ) ;

modelsTable . setColumnCollapsingAllowed ( true ) ;

modelsTable . setPageLength (10) ;

}p . addComponent ( modelsTable ) ;

Button btnAddQuestion = new Button ( ”Add new UML model” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

umlAdd ( ) ;

}90 }) ;

p . addComponent ( btnAddQuestion ) ;

}

public void umlAdd ( ) {ctrlUmlModel = a p p l i c a t i o n . getCtrlUmlModel ( ) ;

a p p l i c a t i o n . setArea ( ” Create a new UML model . . . ” ) ;

body . removeAllComponents ( ) ;

f ina l Panel p = new Panel ( ”” ) ;

100 p . s e tS i z eUnde f ined ( ) ;

body . addComponent (p) ;

body . setComponentAlignment (p , Alignment .TOP CENTER) ;

f ina l Model mdl = new Model ( ) ;

mdl . s e t D e s c r i p t i o n ( ”” ) ;

BeanItem<Model> mdlItem = new BeanItem<Model>(mdl ) ;

f ina l Form addingForm = new Form ( ) ;

addingForm . setWriteThrough ( fa l se ) ;

110 addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new ModelFie ldFactory ( ) ) ;

addingForm . setItemDataSource ( mdlItem ) ;

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays

. a s L i s t (new St r ing [ ] { ” d e s c r i p t i o n ” }) ) ;

445

Page 464: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

120 addingForm . commit ( ) ;

a p p l i c a t i o n . getCtrlUmlModel ( ) . c r ea teStep1 (mdl ) ;

}}) ;

p . addComponent ( addingForm ) ;

p . addComponent ( apply ) ;

}

130 public void umlAddLoadEcore ( Model tmpModel ) {ctrlUmlModel = a p p l i c a t i o n . getCtrlUmlModel ( ) ;

a p p l i c a t i o n . setArea ( ”Upload UML model f i l e s . . . ” ) ;

body . removeAllComponents ( ) ;

modelGridL = new GridLayout (2 , 2) ;

modelGridL . se tSpac ing ( true ) ;

modelGridL . setMargin ( true ) ;

modelGridL . s e t S i z e F u l l ( ) ;

body . addComponent ( modelGridL ) ;

body . setComponentAlignment ( modelGridL , Alignment .TOP LEFT) ;

140 f ina l Panel p = new Panel ( ”Chose the ECORE f i l e ” ) ;

p . s e tS i z eUnde f ined ( ) ;

Vert i ca lLayout vertL = new Vert i ca lLayout ( ) ;

vertL . addComponent (p) ;

modelGridL . removeComponent (1 , 0) ;

modelGridL . addComponent ( vertL , 1 , 0) ;

Panel pStatus = new Panel ( ” F i l e upload s t a t u s ” ) ;

Vert i ca lLayout vertL2 = new Vert i ca lLayout ( ) ;

vertL2 . addComponent ( pStatus ) ;

modelGridL . removeComponent (1 , 1) ;

150 modelGridL . addComponent ( vertL2 , 1 , 1) ;

Panel pDett = new Panel ( ” D e t a i l s ” ) ;

modelGridL . removeComponent (0 , 0) ;

f ina l Upload upload = new Upload ( ”” , ctrlUmlModel ) ;

upload . setImmediate ( true ) ;

upload . setButtonCaption ( ”Upload F i l e ” ) ;

f ina l Button cance lP roc e s s i ng = new Button ( ” Cancel ” ) ;

c anc e lP roc e s s i ng . addLis tener (new Button . C l i c k L i s t e n e r ( ) {160 public void buttonCl ick ( ClickEvent event ) {

upload . interruptUpload ( ) ;

}}) ;

c anc e lP roc e s s i ng . s e t V i s i b l e ( fa l se ) ;

c anc e lP roc e s s i ng . setStyleName ( ” smal l ” ) ;

f ina l Label s t a t e = new Label ( ) ;

f ina l Label r e s u l t = new Label ( ) ;

f ina l Label f i leName = new Label ( ) ;

170 f ina l Label t e x t u a l P ro g r e s s = new Label ( ) ;

f ina l P r o g r e s s I n d i c a t o r p i = new P r o g r e s s I n d i c a t o r ( ) ;

446

Page 465: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

pStatus . s e tS i z eUnde f ined ( ) ;

FormLayout l = new FormLayout ( ) ;

l . setMargin ( true ) ;

Hor izonta lLayout stateLayout = new Horizonta lLayout ( ) ;

s tateLayout . s e tSpac ing ( true ) ;

s tateLayout . addComponent ( s t a t e ) ;

s tateLayout . addComponent ( canc e lP roc e s s i ng ) ;

180 stateLayout . setCapt ion ( ” Current s t a t e ” ) ;

s t a t e . setValue ( ” I d l e ” ) ;

l . addComponent ( stateLayout ) ;

f i leName . setCapt ion ( ” F i l e name” ) ;

l . addComponent ( f i leName ) ;

r e s u l t . setCapt ion ( ” Line breaks counted ” ) ;

l . addComponent ( r e s u l t ) ;

p i . setCapt ion ( ” Progres s ” ) ;

p i . s e t V i s i b l e ( fa l se ) ;

l . addComponent ( p i ) ;

190 t ex t ua l Pr o g r e s s . s e t V i s i b l e ( fa l se ) ;

l . addComponent ( t e x t u a l P ro g r e s s ) ;

upload . addLis tener (new Upload . S t a r t e d L i s t e n e r ( ) {public void uploadStarted ( StartedEvent event ) {

pi . setValue (0 f ) ;

p i . s e t V i s i b l e ( true ) ;

p i . s e t P o l l i n g I n t e r v a l (500) ;

t ex t ua l Pr o g r e s s . s e t V i s i b l e ( true ) ;

s t a t e . setValue ( ” Uploading ” ) ;

200 f i leName . setValue ( event . getFi lename ( ) ) ;

c anc e lP roc e s s i ng . s e t V i s i b l e ( true ) ;

}}) ;

upload . addLis tener (new Upload . P r o g r e s s L i s t e n e r ( ) {public void updateProgress ( long readBytes , long contentLength ) {

pi . setValue (new Float ( readBytes / ( f loat ) contentLength ) ) ;

t ex t ua l Pr o g r e s s . setValue ( ” Processed ” + readBytes

+ ” bytes o f ” + contentLength ) ;

r e s u l t . setValue ( ctrlUmlModel . getLineBreakCount ( )

210 + ” ( count ing . . . ) ” ) ;

}

}) ;

upload . addLis tener (new Upload . SucceededLi s tener ( ) {public void uploadSucceeded ( SucceededEvent event ) {

r e s u l t . setValue ( ctrlUmlModel . getLineBreakCount ( ) + ” ( t o t a l ) ” ) ;

ctrlUmlModel . c r ea teStep2 ( ) ;

}}) ;

220upload . addLis tener (new Upload . F a i l e d L i s t e n e r ( ) {

public void uploadFai l ed ( Fai ledEvent event ) {r e s u l t . setValue ( ctrlUmlModel . getLineBreakCount ( )

+ ” ( count ing in t e r rup t ed at ”

+ Math . round (100 ∗ ( Float ) p i . getValue ( ) ) + ”%)” ) ;

}}) ;

447

Page 466: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

upload . addLis tener (new Upload . F i n i s h e d L i s t e n e r ( ) {230 public void uploadFin ished ( FinishedEvent event ) {

s t a t e . setValue ( ” I d l e ” ) ;

p i . s e t V i s i b l e ( fa l se ) ;

t ex t ua l Pr o g r e s s . s e t V i s i b l e ( fa l se ) ;

c anc e lP roc e s s i ng . s e t V i s i b l e ( fa l se ) ;

}}) ;

p . addComponent ( upload ) ;

pStatus . setContent ( l ) ;

}240

public void umlAddLoadEcoreDiag ( Model tmpModel ) {ctrlUmlModel = a p p l i c a t i o n . getCtrlUmlModel ( ) ;

a p p l i c a t i o n . setArea ( ”Upload UML model f i l e s . . . ” ) ;

body . removeAllComponents ( ) ;

modelGridL = new GridLayout (2 , 2) ;

modelGridL . se tSpac ing ( true ) ;

modelGridL . setMargin ( true ) ;

modelGridL . s e t S i z e F u l l ( ) ;

body . addComponent ( modelGridL ) ;

250 body . setComponentAlignment ( modelGridL , Alignment .TOP LEFT) ;

f ina l Panel p = new Panel ( ”Choose the ECORE−DIAG f i l e ” ) ;

p . s e tS i z eUnde f ined ( ) ;

Vert i ca lLayout vertL = new Vert i ca lLayout ( ) ;

vertL . addComponent (p) ;

modelGridL . removeComponent (1 , 0) ;

modelGridL . addComponent ( vertL , 1 , 0) ;

Panel pStatus = new Panel ( ” F i l e upload s t a t u s ” ) ;

Vert i ca lLayout vertL2 = new Vert i ca lLayout ( ) ;

vertL2 . addComponent ( pStatus ) ;

260 modelGridL . removeComponent (1 , 1) ;

modelGridL . addComponent ( vertL2 , 1 , 1) ;

modelGridL . removeComponent (0 , 0) ;

f ina l Upload upload = new Upload ( ”” , ctrlUmlModel ) ;

upload . setImmediate ( true ) ;

upload . setButtonCaption ( ”Upload F i l e ” ) ;

f ina l Button cance lP roc e s s i ng = new Button ( ” Cancel ” ) ;

c anc e lP roc e s s i ng . addLis tener (new Button . C l i c k L i s t e n e r ( ) {270 public void buttonCl ick ( ClickEvent event ) {

upload . interruptUpload ( ) ;

}}) ;

c anc e lP roc e s s i ng . s e t V i s i b l e ( fa l se ) ;

c anc e lP roc e s s i ng . setStyleName ( ” smal l ” ) ;

f ina l Label s t a t e = new Label ( ) ;

f ina l Label r e s u l t = new Label ( ) ;

f ina l Label f i leName = new Label ( ) ;

280 f ina l Label t e x t u a l P ro g r e s s = new Label ( ) ;

f ina l P r o g r e s s I n d i c a t o r p i = new P r o g r e s s I n d i c a t o r ( ) ;

pStatus . s e tS i z eUnde f ined ( ) ;

FormLayout l = new FormLayout ( ) ;

448

Page 467: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

l . setMargin ( true ) ;

Hor izonta lLayout stateLayout = new Horizonta lLayout ( ) ;

s tateLayout . s e tSpac ing ( true ) ;

s tateLayout . addComponent ( s t a t e ) ;

s tateLayout . addComponent ( canc e lP roc e s s i ng ) ;

290 stateLayout . setCapt ion ( ” Current s t a t e ” ) ;

s t a t e . setValue ( ” I d l e ” ) ;

l . addComponent ( stateLayout ) ;

f i leName . setCapt ion ( ” F i l e name” ) ;

l . addComponent ( f i leName ) ;

r e s u l t . setCapt ion ( ” Line breaks counted ” ) ;

l . addComponent ( r e s u l t ) ;

p i . setCapt ion ( ” Progres s ” ) ;

p i . s e t V i s i b l e ( fa l se ) ;

l . addComponent ( p i ) ;

300 t ex t ua l Pr o g r e s s . s e t V i s i b l e ( fa l se ) ;

l . addComponent ( t e x t u a l P ro g r e s s ) ;

upload . addLis tener (new Upload . S t a r t e d L i s t e n e r ( ) {public void uploadStarted ( StartedEvent event ) {

pi . setValue (0 f ) ;

p i . s e t V i s i b l e ( true ) ;

p i . s e t P o l l i n g I n t e r v a l (500) ;

t ex t ua l Pr o g r e s s . s e t V i s i b l e ( true ) ;

s t a t e . setValue ( ” Uploading ” ) ;

310 f i leName . setValue ( event . getFi lename ( ) ) ;

c anc e lP roc e s s i ng . s e t V i s i b l e ( true ) ;

}}) ;

upload . addLis tener (new Upload . P r o g r e s s L i s t e n e r ( ) {public void updateProgress ( long readBytes , long contentLength ) {

pi . setValue (new Float ( readBytes / ( f loat ) contentLength ) ) ;

t ex t ua l Pr o g r e s s . setValue ( ” Processed ” + readBytes

+ ” bytes o f ” + contentLength ) ;

r e s u l t . setValue ( ctrlUmlModel . getLineBreakCount ( )

320 + ” ( count ing . . . ) ” ) ;

}

}) ;

upload . addLis tener (new Upload . SucceededLi s tener ( ) {public void uploadSucceeded ( SucceededEvent event ) {

r e s u l t . setValue ( ctrlUmlModel . getLineBreakCount ( ) + ” ( t o t a l ) ” ) ;

try {ctrlUmlModel . c r ea teStep3 ( ) ;

} catch ( SaveException e ) {330 e . pr intStackTrace ( ) ;

}}

}) ;

upload . addLis tener (new Upload . F a i l e d L i s t e n e r ( ) {public void uploadFai l ed ( Fai ledEvent event ) {

r e s u l t . setValue ( ctrlUmlModel . getLineBreakCount ( )

+ ” ( count ing in t e r rup t ed at ”

+ Math . round (100 ∗ ( Float ) p i . getValue ( ) ) + ”%)” ) ;

340 }

449

Page 468: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}) ;

upload . addLis tener (new Upload . F i n i s h e d L i s t e n e r ( ) {public void uploadFin ished ( FinishedEvent event ) {

s t a t e . setValue ( ” I d l e ” ) ;

p i . s e t V i s i b l e ( fa l se ) ;

t ex t ua l Pr o g r e s s . s e t V i s i b l e ( fa l se ) ;

c anc e lP roc e s s i ng . s e t V i s i b l e ( fa l se ) ;

}350 }) ;

p . addComponent ( upload ) ;

pStatus . setContent ( l ) ;

}

public void umlDeta i l s ( ) {ctrlUmlModel = a p p l i c a t i o n . getCtrlUmlModel ( ) ;

f ina l Model mdl = ( Model ) modelsTable . getValue ( ) ;

f ina l Panel p = new Panel ( ”Model Id : ” + mdl . getModelId ( ) ) ;

p . s e tS i z eUnde f ined ( ) ;

360 Vert i ca lLayout vertL = new Vert i ca lLayout ( ) ;

vertL . addComponent (p) ;

modelGridL . removeComponent (1 , 0) ;

modelGridL . addComponent ( vertL , 1 , 0) ;

BeanItem<Model> mdlItem = modelsDataSource . getItem (mdl ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

370modifyForm . setFormFieldFactory (new ModelFie ldFactory ( mdl ) ) ;

modifyForm . setItemDataSource ( mdlItem ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays

. a s L i s t (new St r ing [ ] { ” d e s c r i p t i o n ” }) ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {modifyForm . commit ( ) ;

ctrlUmlModel . update ( mdl ) ;

380 p . getWindow ( ) . showNot i f i c a t i on ( ” Conf irmation ” , ”<br/>” ,

N o t i f i c a t i o n .TYPE TRAY NOTIFICATION) ;

modelsTable . r eques tRepa intAl l ( ) ;

} catch ( SaveException e ) {p . getWindow ( ) . showNot i f i c a t i on ( ” Error ” ,

”<br/>” + e . t oS t r i ng ( ) ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}}

}) ;

390 Button d i s ca rd = new Button ( ” Discard ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

modifyForm . d i s ca rd ( ) ;

}}) ;

p . addComponent ( modifyForm ) ;

450

Page 469: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

Horizonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent ( d i s ca rd ) ;

400 p . addComponent ( btnLayout ) ;

}

}

D.6.9 Classe MyLoginForm.java

package i t . uniroma2 . norge . web ;

import i t . uniroma2 . norge . c o n t r o l l e r . LoggedUser ;

import i t . uniroma2 . norge . c o n t r o l l e r . LoginException ;

import com . vaadin . t e rmina l . S i z e a b l e ;

import com . vaadin . t e rmina l . gwt . c l i e n t . Appl icat ionConnect ion ;

import com . vaadin . u i . LoginForm ;

10 public class MyLoginForm extends LoginForm {

private LoggedUser loggedUser ;

private St r ing usernameCaption ;

private St r ing passwordCaption ;

private St r ing submitCaption ;

public MyLoginForm( LoggedUser usr ) {loggedUser = usr ;

20 this . usernameCaption = ”Username” ;

this . passwordCaption = ”Password” ;

this . submitCaption = ”Log in ” ;

this . addLis tener (new Log inL i s t ene r ( ) {

@Override

public void onLogin ( LoginEvent event ) {try {

loggedUser . formLogin ( event . getLoginParameter ( ”username” ) ,

30 event . getLoginParameter ( ”password” ) ) ;

} catch ( LoginException e ) {}

}}) ;

this . setWidth (500 , S i z e a b l e . UNITS PIXELS) ;

this . s e tHe ight (300 , S i z e a b l e . UNITS PIXELS) ;

}

40 @Override

protected byte [ ] getLoginHTML ( ) {St r ing appUri = ge tApp l i ca t i on ( ) . getURL ( ) . t oS t r i ng ( )

+ getWindow ( ) . getName ( ) + ”/” ;

S t r ing x , h , b ;

451

Page 470: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

x = ”<!DOCTYPE html PUBLIC \”−//W3C//DTD ”

+ ”XHTML 1.0 T r a n s i t i o n a l //EN\” ”

+ ”\” http ://www. w3 . org /TR/xhtml1/”

+ ”DTD/xhtml1−t r a n s i t i o n a l . dtd\”>\n” ;

h = ”<head><s c r i p t type=’ t ext / j a v a s c r i p t ’>”

50 + ” var setTarget = func t i on ( ) {” + ” var u r i = ’ ”

+ appUri

+ ” log inHandle r ’ ; ”

+ ” var f = document . getElementById ( ’ l o g i n f ’ ) ; ”

+ ” document . forms [ 0 ] . a c t i on = u r i ; ”

+ ” document . forms [ 0 ] . username . f o cu s ( ) ; ”

+ ” } ; ”

+ ””

+ ” var s t y l e s = window . parent . document . s t y l e S h e e t s ; ”

+ ” f o r ( var j = 0 ; j < s t y l e s . l ength ; j++) {\n”

60 + ” i f ( s t y l e s [ j ] . h r e f ) {”

+ ” var s t y l e s h e e t = document . createElement ( ’ l i n k ’ ) ;\n”

+ ” s t y l e s h e e t . s e t A t t r i b u t e ( ’ r e l ’ , ’ s t y l e s h e e t ’ ) ;\n”

+ ” s t y l e s h e e t . s e t A t t r i b u t e ( ’ type ’ , ’ t ex t / c s s ’ ) ;\n”

+ ” s t y l e s h e e t . s e t A t t r i b u t e ( ’ h r e f ’ , s t y l e s [ j ] . h r e f ) ;\n”

+ ” document . getElementsByTagName ( ’ head ’ ) [ 0 ] ”

+ ” . appendChild ( s t y l e s h e e t ) ;\n”

+ ” }”

+ ”}\n”

+ ” func t i on submitOnEnter ( e ) {”

70 + ” var keycode = e . keyCode | | e . which ; ”

+ ” i f ( keycode == 13) {document . forms [ 0 ] . submit ( ) ;} ”

+ ”}\n”

+ ”</s c r i p t >” + ”</head>” ;

b = ”<body onload=’ setTarget ( ) ; ’ ”

+ ” s t y l e =’margin : 0 ; padding : 0 ; background : t ransparent ; ’ ”

+ ” c l a s s =’”

+ Appl icat ionConnect ion .GENERATED BODY CLASSNAME

+ ”’>”

+ ”<div c l a s s =’v−app v−app−l og inpage ’ ”

80 + ” s t y l e =’background : t ransparent ; ’>”

+ ”<i f rame name=’ l o g i n t a r g e t ’ s t y l e =’width : 0 ; he ight : 0 ; ”

+ ” border : 0 ; margin : 0 ; padding :0; ’></ i frame>”

+ ”<form id =’ l o g i n f ’ t a r g e t =’ l o g i n t a r g e t ’ ”

+ ” onkeypress =’submitOnEnter ( event ) ’ ”

+ ” method=’ post ’>”

+ ”<DIV id =’ log in−page−content’><DIV id =’ log in−page ’>”

+ ”<t ab l e a l i g n =’ cen te r ’>”

+ ”<tr><td><IMG s r c =’/tesiWebApp/VAADIN/themes/mytheme/ l o g i n . g i f ’

a l t =’Login’>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td>”

+ ”<DIV id =’normal−l o g i n ’>”

90 + ”<P><LABEL f o r =’ u s e r s e s s i o n l o g i n ’>”

+ usernameCaption

+ ”</LABEL><BR>”

+ ”<INPUT id =’ u s e r s e s s i o n l o g i n ’ name=’username ’ s i z e = ’30 ’ type=’ t ext ’

c l a s s =’v−t e x t f i e l d ’></P>”

+ ”<P><LABEL f o r =’ u s e r s e s s i o n p a s s w o r d ’>”

+ passwordCaption

+ ”</LABEL><BR>”

+ ”<INPUT id =’ u s e r s e s s i o n p a s s w o r d ’ name=’password ’ s i z e = ’30 ’

type=’password ’ c l a s s =’v−t e x t f i e l d ’></P>”

452

Page 471: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

+ ”</DIV>”

+ ”<tr><td></td><td s t y l e =’ text−a l i g n : c en te r ’>”

100 + ”<div o n c l i c k =’document . forms [ 0 ] . submit ( ) ; ’ ”

+ ” tabindex = ’0 ’ c l a s s =’v−button ’ r o l e =’button ’>”

+ ”<span c l a s s =’v−button−wrap’>”

+ ”<span c l a s s =’v−button−capt ion ’>”

+ submitCaption

+ ”</span>”

+ ”</span></div>”

+ ”</td></tr>”

+ ”</table>”

+ ”</DIV>”

110 + ”</DIV>” + ”</form></div></body>” ;

return ( x + ”<html>” + h + b + ”</html>” ) . getBytes ( ) ;

}

public void setMargin (boolean b) {}

}

D.6.10 Classe MyMenuBar.java

package i t . uniroma2 . norge . web ;

import i t . uniroma2 . norge . c o n t r o l l e r . LoggedUser ;

import i t . uniroma2 . norge . web . support . MenuLinks ;

import com . vaadin . t e rmina l . ThemeResource ;

import com . vaadin . u i . Button ;

import com . vaadin . u i . Hor izonta lLayout ;

import com . vaadin . u i . Vert i ca lLayout ;

10 import com . vaadin . u i . Button . Cl ickEvent ;

import com . vaadin . u i . Button . C l i c k L i s t e n e r ;

public class MyMenuBar extends Vert i ca lLayout {

private Horizonta lLayout menubar ;

public MyMenuBar( ) {menubar = new Horizonta lLayout ( ) ;

addComponent ( menubar ) ;

20 }

public void r e f r e s h ( LoggedUser user , f ina l TesiwebAppl icat ion appl ) {menubar . removeAllComponents ( ) ;

i f ( user . i sLogged ( ) ) {

i f ( user . i s Ro l e ( ”admin” ) ) {Button us e r s = new Button ( ” Users ” ) ;

menubar . addComponent ( u s e r s ) ;

u s e r s . addLis tener (new C l i c k L i s t e n e r ( ) {30 @Override

public void buttonCl ick ( ClickEvent event ) {appl . c t r l U s e r s . menuSelected ( null ) ;

453

Page 472: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}}) ;

u s e r s

. s e t I c on (new ThemeResource (

” . . / runo/ i con s /16/ s e t t i n g s . png” ) ) ;

Button orgs = new Button ( ” Organ izat ions ” ) ;

40 menubar . addComponent ( orgs ) ;

o rgs . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {appl . c t r l O r g a n i z a t i o n s . menuSelected ( null ) ;

}}) ;

u s e r s

. s e t I c on (new ThemeResource (

” . . / runo/ i con s /16/ s e t t i n g s . png” ) ) ;

50 Button umls = new Button ( ”UML model” ) ;

menubar . addComponent ( umls ) ;

umls . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {appl . ctrlUmlModel . menuSelected ( null ) ;

}}) ;

umls . s e t I c o n (new ThemeResource ( ” . . / runo/ i con s /16/ g lobe . png” ) ) ;

60 Button q u e s t i o n n a i r e = new Button ( ” Quest ionna i re ” ) ;

menubar . addComponent ( q u e s t i o n n a i r e ) ;

q u e s t i o n n a i r e . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {appl . c t r lQ ue s t i on . menuSelected ( null ) ;

}}) ;

q u e s t i o n n a i r e . s e t I c o n (new ThemeResource (

” . . / runo/ i con s /16/ a t t e n t i o n . png” ) ) ;

70 }

i f ( user . i s Ro l e ( ”admin” ) ) {Button p r j s = new Button ( ”Agreement” ) ;

menubar . addComponent ( p r j s ) ;

p r j s . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {appl . c t r l P r j . menuSelected ( null ) ;

}80 }) ;

p r j s . s e t I c o n (new ThemeResource ( ” . . / runo/ i con s /16/ g lobe . png” ) ) ;

Button p r j s 2 = new Button ( ” Defau l t d e l i v e r a b l e ” ) ;

menubar . addComponent ( p r j s 2 ) ;

p r j s 2 . addLi s tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {appl . c t r l D e l i v e r a b l e s . menuSelected ( null ) ;

}

454

Page 473: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}) ;

90 p r j s 2 . s e t I c on (new ThemeResource (

” . . / runo/ i con s /16/document−pdf . png” ) ) ;

}

i f ( user . i s Ro l e ( ” s u p p l i e r ” ) ) {Button p r j s 2 = new Button ( MenuLinks . FILLING) ;

menubar . addComponent ( p r j s 2 ) ;

p r j s 2 . addLi s tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {100 appl . c t r l Q u e s t i o n n a i r e . menuSelected ( MenuLinks . FILLING) ;

}}) ;

}i f ( user . i s Ro l e ( ” c e r t i f i e r ” ) ) {

Button p r j s 2 = new Button ( MenuLinks .VALIDATION) ;

menubar . addComponent ( p r j s 2 ) ;

p r j s 2 . addLi s tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {110 appl . c t r l Q u e s t i o n n a i r e

. menuSelected ( MenuLinks .VALIDATION) ;

}}) ;

}

i f ( user . i s Ro l e ( ” s u p p l i e r ” ) | | user . i s Ro l e ( ” c e r t i f i e r ” ) ) {Button p r j s 2 = new Button ( MenuLinks .DELIVERABLE CHECK) ;

menubar . addComponent ( p r j s 2 ) ;

p r j s 2 . addLi s tener (new C l i c k L i s t e n e r ( ) {120 @Override

public void buttonCl ick ( ClickEvent event ) {appl . c t r l D e l i v e r a b l e s . getMenu ( ) . menuSelected ( null ) ;

}}) ;

}Button p r j s 2 = new Button ( MenuLinks .DOCUMENTS) ;

menubar . addComponent ( p r j s 2 ) ;

p r j s 2 . addLi s tener (new C l i c k L i s t e n e r ( ) {@Override

130 public void buttonCl ick ( ClickEvent event ) {appl . ctrlDocument . getMenu ( ) . menuSelected ( null ) ;

}}) ;

} else {}

}

}

D.6.11 Classe OrganizationsUI.java

455

Page 474: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

package i t . uniroma2 . norge . web ;

import i t . uniroma2 . norge . c o n t r o l l e r . Organ izat ionCtr l ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . Organizat ion ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . Organ izat ionFie ldFactory ;

import java . u t i l . Arrays ;

import java . u t i l . L i s t ;

10import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . data . u t i l . BeanItem ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . t e rmina l . S i z e a b l e ;

import com . vaadin . u i . Alignment ;

import com . vaadin . u i . Button ;

import com . vaadin . u i . Form ;

import com . vaadin . u i . GridLayout ;

20 import com . vaadin . u i . Hor izonta lLayout ;

import com . vaadin . u i . Panel ;

import com . vaadin . u i . Table ;

import com . vaadin . u i . Vert i ca lLayout ;

import com . vaadin . u i . Button . Cl ickEvent ;

public class Organizat ionsUI {

private TesiwebAppl icat ion a p p l i c a t i o n ;

30 private Organ izat ionCtr l c t r lOrg s ;

private Vert i ca lLayout body ;

private GridLayout orgGridL ;

private BeanItemContainer<Organizat ion> orgsDataSource ;

public Table orgssTable ;

40 public Organizat ionsUI ( Tes iwebAppl icat ion appl ) {this . a p p l i c a t i o n = appl ;

c t r lOrg s = a p p l i c a t i o n . g e tCt r lOrgan i za t i on s ( ) ;

body = a p p l i c a t i o n . getBody ( ) ;

}

public void o r g s L i s t A l l ( ) {c t r lOrg s = a p p l i c a t i o n . g e tCt r lOrgan i za t i on s ( ) ;

a p p l i c a t i o n . setArea ( ”” ) ;

body . removeAllComponents ( ) ;

50 Panel p = new Panel ( ”” ) ;

p . setWidth (95 , S i z e a b l e .UNITS PERCENTAGE) ;

orgGridL = new GridLayout (2 , 1) ;

orgGridL . se tSpac ing ( true ) ;

orgGridL . setMargin ( true ) ;

orgGridL . s e t S i z e F u l l ( ) ;

orgGridL . addComponent (p , 0 , 0) ;

456

Page 475: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

body . addComponent ( orgGridL ) ;

body . setComponentAlignment ( orgGridL , Alignment .TOP LEFT) ;

60 orgssTable = new Table ( ) ;

orgssTable . s e t S e l e c t a b l e ( true ) ;

orgssTable . setImmediate ( true ) ;

orgssTable . addLis tener ( c t r lOrg s ) ;

orgssTable . addLis tener (new Property . ValueChangeListener ( ) {

@Override

public void valueChange ( ValueChangeEvent event ) {d e l i v D e t a i l s ( ( Organizat ion ) orgssTable . getValue ( ) ) ;

}70 }) ;

L i s t<Organizat ion> datas = c t r lOrg s . getL i s tData ( ) ;

i f ( datas . s i z e ( ) > 0) {orgsDataSource = new BeanItemContainer<Organizat ion >(datas ) ;

orgssTable . setContainerDataSource ( orgsDataSource ) ;

orgssTable . se tVis ib leColumns (new Object [ ] { ”name” , ” country ” ,

” type ” }) ;

orgssTable . setColumnHeaders (new St r ing [ ] { ”Name” , ”Country” ,

”Type” }) ;

orgssTable . setRowHeaderMode ( Table .ROW HEADER MODE PROPERTY) ;

80 orgssTable . setColumnReorderingAllowed ( true ) ;

orgssTable . setColumnCollapsingAllowed ( true ) ;

orgssTable . setPageLength (10) ;

}p . addComponent ( orgssTable ) ;

Button btnAddQuestion = new Button ( ”Add new o rg a n i z a t i o n ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

orgAdd ( ) ;

}90 }) ;

p . addComponent ( btnAddQuestion ) ;

}

public void orgAdd ( ) {c t r lOrg s = a p p l i c a t i o n . g e tCt r lOrgan i za t i on s ( ) ;

a p p l i c a t i o n . setArea ( ” Create a new o r g a n i z a t i o n . . . ” ) ;

body . removeAllComponents ( ) ;

f ina l Panel p = new Panel ( ”New o r g a n i z a t i o n ” ) ;

p . s e tS i z eUnde f ined ( ) ;

100 body . addComponent (p) ;

body . setComponentAlignment (p , Alignment .TOP CENTER) ;

f ina l Organizat ion d = new Organizat ion ( ) ;

d . setName ( ”” ) ;

d . setCountry ( ”” ) ;

BeanItem<Organizat ion> delItem = new BeanItem<Organizat ion >(d) ;

f ina l Form addingForm = new Form ( ) ;

addingForm . setWriteThrough ( fa l se ) ;

110 addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new Organ izat ionFie ldFactory (d) ) ;

457

Page 476: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

addingForm . setItemDataSource ( de l Item ) ;

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”name” , ” country ” , ” type ” }) ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

120 try {addingForm . commit ( ) ;

c t r lOrg s . c r e a t e (d) ;

} catch ( SaveException e ) {a p p l i c a t i o n . showNot i f i c a t i on ( ” Error ” ) ;

}}

}) ;

p . addComponent ( addingForm ) ;

130 p . addComponent ( apply ) ;

}

public void d e l i v D e t a i l s ( Organizat ion de fau l tOrg ) {c t r lOrg s = a p p l i c a t i o n . g e tCt r lOrgan i za t i on s ( ) ;

i f ( orgssTable == null ) {System . out . p r i n t l n ( ” Tabel la non e s i s t e ” ) ;

return ;

}140 i f ( orgssTable . getValue ( ) == null )

System . out . p r i n t l n ( ”Elemento non e s i s t e ” ) ;

f ina l Organizat ion org = defau l tOrg ;

f ina l Panel p = new Panel ( ” D e t a i l s ” ) ;

p . s e tS i z eUnde f ined ( ) ;

Vert i ca lLayout vertL = new Vert i ca lLayout ( ) ;

vertL . addComponent (p) ;

orgGridL . removeComponent (1 , 0) ;

orgGridL . addComponent ( vertL , 1 , 0) ;

150 BeanItem<Organizat ion> delItem = orgsDataSource . getItem ( org ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm

. setFormFieldFactory (new Organ izat ionFie ldFactory ( org ) ) ;

modifyForm . setItemDataSource ( de l Item ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {160 ”name” , ” country ” , ” type ” }) ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {modifyForm . commit ( ) ;

c t r lOrg s . update ( org ) ;

orgssTable . r eques tRepa intAl l ( ) ;

} catch ( SaveException e ) {a p p l i c a t i o n . showNot i f i c a t i on ( ” Error ” ) ;

458

Page 477: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}170 }

}) ;

Button d i s ca rd = new Button ( ” Discard ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

modifyForm . d i s ca rd ( ) ;

}}) ;

p . addComponent ( modifyForm ) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

180 btnLayout . addComponent ( apply ) ;

btnLayout . addComponent ( d i s ca rd ) ;

p . addComponent ( btnLayout ) ;

}

}

D.6.12 Classe PieChart.java

package i t . uniroma2 . norge . web ;

import java . awt . Color ;

import java . awt . image . BufferedImage ;

import java . t ex t . NumberFormat ;

import java . u t i l . HashMap ;

import java . u t i l . L i s t ;

import org . j f r e e . chart . ChartFactory ;

10 import org . j f r e e . chart . JFreeChart ;

import org . j f r e e . chart . l a b e l s . StandardPieSect ionLabe lGenerator ;

import org . j f r e e . chart . p l o t . P iePlot ;

import org . j f r e e . data . category . CategoryDataset ;

import org . j f r e e . data . g ene ra l . De fau l tPieDataset ;

public class PieChart {

private PiePlot p l o t ;

private JFreeChart chart ;

20public PieChart (HashMap<Str ing , Integer> dat i , S t r ing t i t o l o , Color [ ] c o l o r s ) {

Defau l tPieDataset datase t = new Defau l tPieDataset ( ) ;

for ( S t r ing s : da t i . keySet ( ) ) {I n t e g e r k = dat i . get ( s ) ;

datase t . setValue ( s , k ) ;

}chart = ChartFactory . c reatePieChart ( t i t o l o ,

dataset ,

true ,

30 true , fa l se ) ;

p l o t = ( PiePlot ) chart . ge tP lo t ( ) ;

p l o t . setBackgroundPaint ( Color . white ) ;

p l o t . s e t C i r c u l a r ( true ) ;

p l o t . se tLabe lGenerator (new StandardPieSect ionLabe lGenerator (

459

Page 478: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

”{1} ({2} ) ” , NumberFormat . getNumberInstance ( ) , NumberFormat

. ge tPercent Ins tance ( ) ) ) ;

p l o t . setNoDataMessage ( ”No data a v a i l a b l e ” ) ;

PieRenderer r ende re r = new PieRenderer ( c o l o r s ) ;

r ende re r . s e tCo lo r ( plot , datase t ) ;

40 }

public BufferedImage getP lo t ( int w, int h) {BufferedImage image = chart . c reateBuf f e redImage (w, h) ;

return image ;

}

public stat ic class PieRenderer {private Color [ ] c o l o r ;

50 public PieRenderer ( Color [ ] c o l o r ) {this . c o l o r = c o l o r ;

}

public void s e tCo lo r ( PiePlot plot , De fau l tPieDataset datase t ) {List<Comparable> keys = datase t . getKeys ( ) ;

int aInt ;

for ( int i = 0 ; i < keys . s i z e ( ) ; i++) {aInt = i % this . c o l o r . l ength ;

60 p lo t . s e tSe c t i onPa in t ( keys . get ( i ) , this . c o l o r [ a Int ] ) ;

}}

public void s e tCo lo r ( PiePlot plot , CategoryDataset datase t ) {List<Comparable> keys = datase t . getRowKeys ( ) ;

int aInt ;

for ( int i = 0 ; i < keys . s i z e ( ) ; i++) {aInt = i % this . c o l o r . l ength ;

70 p lo t . s e tSe c t i onPa in t ( keys . get ( i ) , this . c o l o r [ a Int ] ) ;

}}

}}

D.6.13 Classe QuestionnaireUI.java

package i t . uniroma2 . norge . web ;

import i t . uniroma2 . norge . c o n t r o l l e r . Que s t i onna i r e sCt r l ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . model . jpa . Alternat iveAnswer ;

import i t . uniroma2 . norge . model . jpa . Question ;

import i t . uniroma2 . norge . model . jpa . Quest ionna i re ;

import i t . uniroma2 . norge . model . jpa . RuleExclus ion ;

import i t . uniroma2 . norge . model . jpa . Ru l eMul t ep l i c i ty ;

10 import i t . uniroma2 . norge . web . f i e l d f a c t o r y . AnswerFieldFactory ;

460

Page 479: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . Quest ionFie ldFactory ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . Ques t i onna i r eF i e ldFactory ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . RuleExcFieldFactory ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . RuleMulFieldFactory ;

import java . i o . S e r i a l i z a b l e ;

import java . u t i l . Arrays ;

import java . u t i l . L i s t ;

20 import com . vaadin . addon . t r e e t a b l e . TreeTable ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . data . u t i l . BeanItem ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . t e rmina l . S i z e a b l e ;

import com . vaadin . u i . Alignment ;

import com . vaadin . u i . Button ;

import com . vaadin . u i . Embedded ;

import com . vaadin . u i . Form ;

30 import com . vaadin . u i . GridLayout ;

import com . vaadin . u i . Hor izonta lLayout ;

import com . vaadin . u i . Panel ;

import com . vaadin . u i . Table ;

import com . vaadin . u i . Vert i ca lLayout ;

import com . vaadin . u i . Window ;

import com . vaadin . u i . Button . Cl ickEvent ;

import com . vaadin . u i . Window . N o t i f i c a t i o n ;

public class Quest ionnaireUI implements S e r i a l i z a b l e {40

private stat ic f ina l long se r ia lVer s ionUID = 295447085169950160L ;

private TesiwebAppl icat ion a p p l i c a t i o n ;

private Ques t i onna i r e sCt r l c t r lQ ue s t i o n ;

private Ques t i onna i r e sCt r l c t r l R u l e ;

private Vert i ca lLayout body ;

50private GridLayout quest ionGridL ;

private BeanItemContainer<Quest ionnaire> quest ionna i reDataSource ;

public Table que s t i onna i r e sTab l e ;

private BeanItemContainer<Question> quest ionsDataSource ;

public Table quest ionsTab le ;

60private BeanItemContainer<AlternativeAnswer> answersDataSource ;

public TreeTable answersTable ;

private BeanItemContainer<RuleExclusion> ru lesExcluDataSource ;

461

Page 480: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public Table ru le sExc luTable ;

private BeanItemContainer<RuleMul tep l i c i ty> rulesMultDataSource ;

70public Table rulesMultTable ;

private Window questionWin ;

private Window answerWin ;

private Window ru lesL i s tWin ;

private Window rulesWin ;

public Quest ionnaireUI ( Tes iwebAppl icat ion appl ) {this . a p p l i c a t i o n = appl ;

80 c t r lQ ue s t i o n = a p p l i c a t i o n . getCtr lQuest ion ( ) ;

body = a p p l i c a t i o n . getBody ( ) ;

}

public void answerAdd ( ) {c t r lQ ue s t i o n = a p p l i c a t i o n . getCtr lQuest ion ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( ru le sL i s tWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( rulesWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( answerWin ) ;

answerWin = new Window( ”New Al t e rna t i v e ” ) ;

90 Vert i ca lLayout p = ( Vert i ca lLayout ) answerWin . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

f ina l Alternat iveAnswer ans = new Alternat iveAnswer ( ) ;

ans . setAnswer ( ”” ) ;

BeanItem<AlternativeAnswer> ansItem = new BeanItem<AlternativeAnswer >(

ans ) ;

100 List<AlternativeAnswer> datas = c t r lQ ue s t i o n . getAnswerListData ( ) ;

f ina l Form addingForm = new Form ( ) ;

addingForm . setWriteThrough ( fa l se ) ;

addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new AnswerFieldFactory ( datas ) ) ;

addingForm . setItemDataSource ( ansItem ) ;

i f ( c t r l Qu e s t i on . getReferenceQuest ion ( ) . getS i lDependent ( ) == null

| | c t r lQ ue s t i o n . getReferenceQuest ion ( ) . getS i lDependent ( ) == fa l se )

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”answer” , ” f a t h e r A l t e r n a t i v e ” }) ) ;

110 else

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”answer” , ” s i l M i n L e v e l S t r i n g ” , ” f a t h e r A l t e r n a t i v e ” }) ) ;

Button apply = new Button ( ”Add” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {addingForm . commit ( ) ;

c t r lQ ue s t i o n . createAnswer ( ans ) ;

answerWin . getWindow ( ) . showNot i f i c a t i on ( ” Conf irmation ” ,

”<br/>” , N o t i f i c a t i o n .TYPE TRAY NOTIFICATION) ;

120 } catch ( SaveException e ) {answerWin . getWindow ( ) . showNot i f i c a t i on ( ” Error ” ,

”<br/>” + e . t oS t r i ng ( ) ,

462

Page 481: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}}

}) ;

p . addComponent ( addingForm ) ;

p . addComponent ( apply ) ;

130 answerWin . c en te r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( answerWin ) ;

}

public void answerDeta i l s ( ) {c t r lQ ue s t i o n = a p p l i c a t i o n . getCtr lQuest ion ( ) ;

c t r l R u l e = a p p l i c a t i o n . getCtr lRule ( ) ;

f ina l Alternat iveAnswer ans = c t r l Qu e s t i on . getReferenceAnswer ( ) ;

i f ( ans == null )

return ;

140 c t r lQ ue s t i o n . r e f r e s h ( ans ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( ru le sL i s tWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( rulesWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( answerWin ) ;

answerWin = new Window( ”Answer d e t a i l s ” ) ;

Vert i ca lLayout pW = ( Vert i ca lLayout ) answerWin . getContent ( ) ;

pW. setMargin ( true ) ;

pW. setSpac ing ( true ) ;

pW. se tS i z eUnde f ined ( ) ;

f ina l Panel p = new Panel ( ”” ) ;

150 p . s e tS i z eUnde f ined ( ) ;

f ina l Panel po = new Panel ( ” Operat ions ” ) ;

po . s e tS i z eUnde f ined ( ) ;

Hor izonta lLayout h = new Horizonta lLayout ( ) ;

po . setContent (h) ;

BeanItem<AlternativeAnswer> ansItem = new BeanItem<AlternativeAnswer >(

ans ) ;

L i s t<AlternativeAnswer> datas = c t r lQ ue s t i o n . getAnswerListData ( ) ;

160 f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm . setFormFieldFactory (new AnswerFieldFactory ( ans , datas ) ) ;

modifyForm . setItemDataSource ( ansItem ) ;

i f ( c t r l Qu e s t i on . getReferenceQuest ion ( ) . getS i lDependent ( ) == null

| | c t r lQ ue s t i o n . getReferenceQuest ion ( ) . getS i lDependent ( ) == fa l se )

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”answer” , ” f a t h e r A l t e r n a t i v e ” }) ) ;

170 else

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”answer” , ” s i l M i n L e v e l S t r i n g ” , ” f a t h e r A l t e r n a t i v e ” }) ) ;

Button apply = new Button ( ”Save and c l o s e ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {modifyForm . commit ( ) ;

c t r lQ ue s t i o n . update ( ans ) ;

p . getWindow ( ) . showNot i f i c a t i on ( ” Conf irmation ” , ”<br/>” ,

463

Page 482: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

N o t i f i c a t i o n .TYPE TRAY NOTIFICATION) ;

180 answersTable . r eques tRepa intAl l ( ) ;

} catch ( SaveException e ) {p . getWindow ( ) . showNot i f i c a t i on ( ” Error ” ,

”<br/>” + e . t oS t r i ng ( ) ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}}

}) ;

Button d i s ca rd = new Button ( ” Close without sav ing ” ,

new Button . C l i c k L i s t e n e r ( ) {190 public void buttonCl ick ( ClickEvent event ) {

q u e s t i o n D e t a i l s ( ) ;

}}) ;

Button btnExclus ionRules = new Button ( ” Rules o f e x c l u s i o n ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

c t r l R u l e . v i ewAl lExc lus ion ( ans ) ;

}}) ;

200 Button btnMultRules = new Button ( ” Rules o f m u l t e p l i c i t y ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

c t r l R u l e . v i e w A l l M u l t e p l i c i t y ( ans ) ;

}}) ;

p . addComponent ( modifyForm ) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent ( d i s ca rd ) ;

210 p . addComponent ( btnLayout ) ;

po . addComponent ( btnExclus ionRules ) ;

po . addComponent ( btnMultRules ) ;

pW. addComponent (p) ;

pW. addComponent ( po ) ;

answerWin . c en te r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( answerWin ) ;

}

public void exclusionAdd ( ) {220 c t r l R u l e = a p p l i c a t i o n . getCtr lRule ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( rulesWin ) ;

rulesWin = new Window( ”New e x c l u s i o n r u l e ” ) ;

f ina l Vert i ca lLayout p = ( Vert i ca lLayout ) rulesWin . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

f ina l RuleExclus ion r = new RuleExclus ion ( ) ;

BeanItem<RuleExclusion> rItem = new BeanItem<RuleExclusion >(r ) ;

230f ina l Form addingForm = new Form ( ) ;

addingForm . setWriteThrough ( fa l se ) ;

addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new RuleExcFieldFactory ( a p p l i c a t i o n

464

Page 483: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

. ge tCtr lQuest ion ( ) . ge tRe fQues t ionna i re ( ) ) ) ;

addingForm . setItemDataSource ( rItem ) ;

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {” ques t i on ” , ” a l te rnat iveAnswerTarget ” }) ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {240 public void buttonCl ick ( ClickEvent event ) {

try {addingForm . commit ( ) ;

c t r l R u l e . c reateRule ( r ) ;

p . getWindow ( ) . showNot i f i c a t i on ( ” Conf irmation ” , ”<br/>” ,

N o t i f i c a t i o n .TYPE TRAY NOTIFICATION) ;

} catch ( SaveException e ) {p . getWindow ( ) . showNot i f i c a t i on ( ” Error ” ,

”<br/>” + e . t oS t r i ng ( ) ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

250 }}

}) ;

p . addComponent ( addingForm ) ;

p . addComponent ( apply ) ;

rulesWin . c en te r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( rulesWin ) ;

}

260 public void e x c l u s i o n D e t a i l s ( ) {c t r l R u l e = a p p l i c a t i o n . getCtr lRule ( ) ;

f ina l RuleExclus ion r = ( RuleExclus ion ) ru le sExc luTable . getValue ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( ru le sL i s tWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( rulesWin ) ;

rulesWin = new Window( ” Exc lus ion r u l e ” ) ;

f ina l Vert i ca lLayout p = ( Vert i ca lLayout ) rulesWin . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

270BeanItem<RuleExclusion> rItem = new BeanItem<RuleExclusion >(r ) ;

f ina l Form addingForm = new Form ( ) ;

addingForm . setWriteThrough ( fa l se ) ;

addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new RuleExcFieldFactory ( r , a p p l i c a t i o n

. getCtr lQuest ion ( ) . ge tRe fQues t ionna i re ( ) ) ) ;

addingForm . setItemDataSource ( rItem ) ;

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {280 ” ques t i on ” , ” a l te rnat iveAnswerTarget ” }) ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {addingForm . commit ( ) ;

c t r l R u l e . update ( r ) ;

p . getWindow ( ) . showNot i f i c a t i on ( ” Conf irmation ” , ”<br/>” ,

N o t i f i c a t i o n .TYPE TRAY NOTIFICATION) ;

ru le sExc luTable . r eques tRepa intAl l ( ) ;

} catch ( SaveException e ) {290 p . getWindow ( ) . showNot i f i c a t i on ( ” Error ” ,

465

Page 484: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

”<br/>” + e . t oS t r i ng ( ) ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}}

}) ;

p . addComponent ( addingForm ) ;

p . addComponent ( apply ) ;

rulesWin . c en te r ( ) ;

300 a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( rulesWin ) ;

}

public void e x c l u s i o n L i s t ( ) {c t r l R u l e = a p p l i c a t i o n . getCtr lRule ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( rulesWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( ru le sL i s tWin ) ;

ru le sL i s tWin = new Window( ” Exc lus ion r u l e s ” ) ;

Vert i ca lLayout pA = ( Vert i ca lLayout ) ru le sL i s tWin . getContent ( ) ;

pA. setMargin ( true ) ;

310 pA. se tSpac ing ( true ) ;

pA. s e tS i z eUnde f ined ( ) ;

ru l e sExc luTable = new Table ( ) ;

ru l e sExc luTable . s e t S e l e c t a b l e ( true ) ;

ru l e sExc luTable . setImmediate ( true ) ;

ru l e sExc luTable . addLis tener ( c t r l R u l e . ge tRu le sExc luSe l ec t ed ( ) ) ;

L i s t<RuleExclusion> datas = c t r l R u l e . getRulesExc luListData ( ) ;

i f ( datas . s i z e ( ) > 0) {ru lesExcluDataSource = new BeanItemContainer<RuleExclusion >(datas ) ;

320 ru le sExc luTable . setContainerDataSource ( ru lesExcluDataSource ) ;

ru l e sExc luTable . setVis ib leColumns (new Object [ ] { ” q u e s t i on S t r i n g ” ,

” a l te rnat iveAnswerTarget ” }) ;

ru l e sExc luTable . setColumnHeaders (new St r ing [ ] { ” Question ” ,

”Answer” }) ;

ru l e sExc luTable . set ItemCapt ionPropertyId ( ” ru l eExc lu s i on Id ” ) ;

ru le sExc luTable . setColumnReorderingAllowed ( fa l se ) ;

ru l e sExc luTable . setColumnCollapsingAllowed ( fa l se ) ;

ru l e sExc luTable . setPageLength (6 ) ;

pA. addComponent ( ru le sExc luTable ) ;

330 } else {pA

. getWindow ( )

. showNot i f i c a t i on (

”No datas ” ,

”<br/>There aren ’ t any an f o r t h i s p r o j e c t . ”

+ ”<br/><br/>You can add a new ques t i on by c l i c k i n g the button . ” ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}Button btnAddAnsware = new Button ( ”Add new r u l e ” ,

340 new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

c t r l R u l e . addExclusionRule ( ) ;

}}) ;

pA. addComponent ( btnAddAnsware ) ;

ru l e sL i s tWin . c en t e r ( ) ;

466

Page 485: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( ru le sL i s tWin ) ;

}

350 public void multep l i c i tyAdd ( ) {c t r l R u l e = a p p l i c a t i o n . getCtr lRule ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( rulesWin ) ;

rulesWin = new Window( ”New m u l t e p l i c i t y r u l e ” ) ;

f ina l Vert i ca lLayout p = ( Vert i ca lLayout ) rulesWin . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

f ina l RuleMul t ep l i c i ty r = new RuleMul t ep l i c i ty ( ) ;

360 BeanItem<RuleMul tep l i c i ty> rItem = new BeanItem<RuleMultep l i c i ty >(r ) ;

f ina l Form addingForm = new Form ( ) ;

addingForm . setWriteThrough ( fa l se ) ;

addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new RuleMulFieldFactory ( a p p l i c a t i o n

. getCtr lQuest ion ( ) . ge tRe fQues t ionna i re ( ) ) ) ;

addingForm . setItemDataSource ( rItem ) ;

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {” ques t i on ” , ” type ” , ” lowebound” , ”upperbound” }) ) ;

370 Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {addingForm . commit ( ) ;

c t r l R u l e . c reateRule ( r ) ;

p . getWindow ( ) . showNot i f i c a t i on ( ” Conf irmation ” , ”<br/>” ,

N o t i f i c a t i o n .TYPE TRAY NOTIFICATION) ;

} catch ( SaveException e ) {p . getWindow ( ) . showNot i f i c a t i on ( ” Error ” ,

”<br/>” + e . t oS t r i ng ( ) ,

380 N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}}

}) ;

p . addComponent ( addingForm ) ;

p . addComponent ( apply ) ;

rulesWin . c en te r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( rulesWin ) ;

}390

public void m u l t e p l i c i t y D e t a i l s ( ) {c t r l R u l e = a p p l i c a t i o n . getCtr lRule ( ) ;

f ina l RuleMul t ep l i c i ty r = ( Ru l eMul t ep l i c i ty ) ru lesMultTable . getValue ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( rulesWin ) ;

rulesWin = new Window( ” M u l t e p l i c i t y r u l e ” ) ;

f ina l Vert i ca lLayout p = ( Vert i ca lLayout ) rulesWin . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

400BeanItem<RuleMul tep l i c i ty> rItem = new BeanItem<RuleMultep l i c i ty >(r ) ;

467

Page 486: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

f ina l Form addingForm = new Form ( ) ;

addingForm . setWriteThrough ( fa l se ) ;

addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new RuleMulFieldFactory ( r , a p p l i c a t i o n

. getCtr lQuest ion ( ) . ge tRe fQues t ionna i re ( ) ) ) ;

addingForm . setItemDataSource ( rItem ) ;

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {410 ” ques t i on ” , ” type ” , ” lowebound” , ”upperbound” }) ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {addingForm . commit ( ) ;

c t r l R u l e . update ( r ) ;

p . getWindow ( ) . showNot i f i c a t i on ( ” Conf irmation ” , ”<br/>” ,

N o t i f i c a t i o n .TYPE TRAY NOTIFICATION) ;

ru lesMultTable . r eques tRepa intAl l ( ) ;

} catch ( SaveException e ) {420 p . getWindow ( ) . showNot i f i c a t i on ( ” Error ” ,

”<br/>” + e . t oS t r i ng ( ) ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}}

}) ;

p . addComponent ( addingForm ) ;

p . addComponent ( apply ) ;

rulesWin . c en te r ( ) ;

430 a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( rulesWin ) ;

}

public void m u l t e p l i c i t y L i s t ( ) {c t r l R u l e = a p p l i c a t i o n . getCtr lRule ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( rulesWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( ru le sL i s tWin ) ;

ru le sL i s tWin = new Window( ” M u l t e p l i c i t y r u l e s ” ) ;

Vert i ca lLayout pA = ( Vert i ca lLayout ) ru le sL i s tWin . getContent ( ) ;

pA. setMargin ( true ) ;

440 pA. se tSpac ing ( true ) ;

pA. s e tS i z eUnde f ined ( ) ;

ru lesMultTable = new Table ( ) ;

ru lesMultTable . s e t S e l e c t a b l e ( true ) ;

ru lesMultTable . setImmediate ( true ) ;

ru lesMultTable . addLis tener ( c t r l R u l e . getRulesMultepSe lected ( ) ) ;

L i s t<RuleMul tep l i c i ty> datas = c t r l R u l e . getRulesMulteListData ( ) ;

i f ( datas . s i z e ( ) > 0) {rulesMultDataSource = new BeanItemContainer<RuleMultep l i c i ty >(datas ) ;

450 ru lesMultTable . setContainerDataSource ( rulesMultDataSource ) ;

ru lesMultTable

. setVis ib leColumns (new Object [ ] { ” ques t i on ” , ” type ” }) ;

ru lesMultTable

. setColumnHeaders (new St r ing [ ] { ” Question ” , ”Type” }) ;

ru lesMultTable . set ItemCapt ionPropertyId ( ” r u l e M u l t e p l i c i t y I d ” ) ;

ru lesMultTable . setColumnReorderingAllowed ( fa l se ) ;

ru lesMultTable . setColumnCollapsingAllowed ( fa l se ) ;

ru lesMultTable . setPageLength (6 ) ;

468

Page 487: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

pA. addComponent ( rulesMultTable ) ;

460 } else {pA

. getWindow ( )

. showNot i f i c a t i on (

”No datas ” ,

”<br/>There aren ’ t any an f o r t h i s p r o j e c t . ”

+ ”<br/><br/>You can add a new ques t i on by c l i c k i n g the button . ” ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}Button btnAddAnsware = new Button ( ”Add new r u l e ” ,

470 new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

c t r l R u l e . addMultep l i c i tyRule ( ) ;

}}) ;

pA. addComponent ( btnAddAnsware ) ;

ru l e sL i s tWin . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( ru le sL i s tWin ) ;

}

480 public void questionAdd ( ) {c t r lQ ue s t i o n = a p p l i c a t i o n . getCtr lQuest ion ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( ru le sL i s tWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( rulesWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( answerWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( questionWin ) ;

questionWin = new Window( ”New Question ” ) ;

f ina l Vert i ca lLayout p = ( Vert i ca lLayout ) questionWin . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

490 p . s e tS i z eUnde f ined ( ) ;

f ina l Question qst = new Question ( ) ;

qs t . s e tQuest ion ( ”” ) ;

qs t . se tS i lDependent ( fa l se ) ;

qs t . s e tQue s t i onna i r e ( c t r l Qu e s t i on . ge tRe fQuest ionna i r e ( ) ) ;

BeanItem<Question> qstItem = new BeanItem<Question >(qs t ) ;

f ina l Form addingForm = new Form ( ) ;

addingForm . setWriteThrough ( fa l se ) ;

500 addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new Quest ionFie ldFactory ( qst ) ) ;

addingForm . setItemDataSource ( qstItem ) ;

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {” ques t i on ” , ” s i n g l e M u l t i p l e ” , ” lowerbound” , ”upperbound” ,

” s i lDependent ” , ” c o n t e x t D e f i n i t i o n ” , ” openQuestion ” ,

”mpackage” , ” mclass ” }) ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {510 addingForm . commit ( ) ;

c t r lQ ue s t i o n . c r e a t e ( qst ) ;

p . getWindow ( ) . showNot i f i c a t i on ( ” Conf irmation ” , ”<br/>” ,

N o t i f i c a t i o n .TYPE TRAY NOTIFICATION) ;

} catch ( SaveException e ) {

469

Page 488: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

p . getWindow ( ) . showNot i f i c a t i on ( ” Error ” ,

”<br/>” + e . t oS t r i ng ( ) ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}}

520 }) ;

p . addComponent ( addingForm ) ;

p . addComponent ( apply ) ;

questionWin . c en te r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( questionWin ) ;

}

public void q u e s t i o n D e t a i l s ( ) {c t r lQ ue s t i o n = a p p l i c a t i o n . getCtr lQuest ion ( ) ;

530 f ina l Question qst = c t r l Q ue s t i o n . getReferenceQuest ion ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( ru le sL i s tWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( rulesWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( answerWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( questionWin ) ;

i f ( qs t == null )

return ;

questionWin = new Window( ” Question d e t a i l s ” ) ;

f ina l Horizonta lLayout pW = new Horizonta lLayout ( ) ;

questionWin . setContent (pW) ;

540 pW. setMargin ( true ) ;

pW. setSpac ing ( true ) ;

pW. se tS i z eUnde f ined ( ) ;

f ina l Panel p = new Panel ( ” Question d e t a i l s ” ) ;

p . s e tS i z eUnde f ined ( ) ;

f ina l Panel pA = new Panel ( ” A l t e rna t i v e Answer” ) ;

pA. s e tS i z eUnde f ined ( ) ;

BeanItem<Question> qstItem = new BeanItem<Question >(qs t ) ;

550 f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm . setFormFieldFactory (new Quest ionFie ldFactory ( qst ) ) ;

modifyForm . setItemDataSource ( qstItem ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {” ques t i on ” , ” s i n g l e M u l t i p l e ” , ” lowerbound” , ”upperbound” ,

” s i lDependent ” , ” c o n t e x t D e f i n i t i o n ” , ” openQuestion ” ,

”mpackage” , ” mclass ” }) ) ;

560 Button apply = new Button ( ”Save and c l o s e ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {modifyForm . commit ( ) ;

c t r lQ ue s t i o n . update ( qst ) ;

p . getWindow ( ) . showNot i f i c a t i on ( ” Conf irmation ” , ”<br/>” ,

N o t i f i c a t i o n .TYPE TRAY NOTIFICATION) ;

} catch ( SaveException e ) {p . getWindow ( ) . showNot i f i c a t i on ( ” Error ” ,

”<br/>” + e . t oS t r i ng ( ) ,

570 N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

470

Page 489: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}}

}) ;

Button d i s ca rd = new Button ( ” Close without sav ing ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

q u e s t i o n s L i s t ( ) ;

}}) ;

580 answersTable = new TreeTable ( ) ;

answersTable . s e t S e l e c t a b l e ( true ) ;

answersTable . setImmediate ( true ) ;

answersTable . addLis tener ( c t r lQ ue s t i on . getAnswerSe lected ( ) ) ;

L i s t<AlternativeAnswer> datas = c t r lQ ue s t i o n . getAnswerListData ( ) ;

i f ( datas . s i z e ( ) > 0) {answersDataSource = new BeanItemContainer<AlternativeAnswer >(datas ) ;

answersTable . setContainerDataSource ( answersDataSource ) ;

for ( Alternat iveAnswer a : datas ) {i f ( a . g e tFathe rA l t e rna t iv e ( ) == null ) {

590 i f ( a . g e tSonAl t e rnat ive s ( ) != null

&& a . ge tSonAl t e rna t ive s ( ) . s i z e ( ) > 0) {for ( Alternat iveAnswer b : a . g e tSonAl t e rna t ive s ( ) ) {

answersTable . se tParent (b , a ) ;

answersTable . setChi ldrenAl lowed (b , fa l se ) ;

}} else {

answersTable . setChi ldrenAl lowed ( a , fa l se ) ;

}}

600 }i f ( qs t . getS i lDependent ( ) == null | | qst . getS i lDependent ( ) == fa l se ) {

answersTable . se tVis ib leColumns (new Object [ ] { ”answer” }) ;

answersTable . setColumnHeaders (new St r ing [ ] { ”Answer” }) ;

} else {answersTable . se tVis ib leColumns (new Object [ ] { ”answer” ,

” s i l M i n L e v e l S t r i n g ” }) ;

answersTable . setColumnHeaders (new St r ing [ ] { ”Answer” ,

”Min . SIL” }) ;

}610 answersTable . set ItemCapt ionPropertyId ( ” answerId ” ) ;

answersTable . setColumnReorderingAllowed ( fa l se ) ;

answersTable . setColumnCollapsingAllowed ( fa l se ) ;

answersTable . setPageLength (12) ;

pA. addComponent ( answersTable ) ;

} else {}Button btnAddAnsware = new Button ( ”Add answer” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

620 c t r lQ ue s t i o n . addAnswer ( ) ;

}}) ;

p . addComponent ( modifyForm ) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent ( d i s ca rd ) ;

471

Page 490: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

p . addComponent ( btnLayout ) ;

pA. addComponent ( btnAddAnsware ) ;

pW. addComponent (p) ;

630 pW. addComponent (pA) ;

questionWin . c en te r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( questionWin ) ;

}

public void quest ionnaireAdd ( ) {c t r lQ ue s t i o n = a p p l i c a t i o n . getCtr lQuest ion ( ) ;

a p p l i c a t i o n . setArea ( ”” ) ;

body . removeAllComponents ( ) ;

640 f ina l Panel p = new Panel ( ”” ) ;

p . s e tS i z eUnde f ined ( ) ;

body . addComponent (p) ;

body . setComponentAlignment (p , Alignment .TOP CENTER) ;

f ina l Quest ionna i re qst = new Quest ionna i re ( ) ;

qs t . setName ( ”” ) ;

BeanItem<Quest ionnaire> prj I tem = new BeanItem<Quest ionnaire >(qst ) ;

f ina l Form addingForm = new Form ( ) ;

650 addingForm . setWriteThrough ( fa l se ) ;

addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new Quest ionna i r eF i e ldFactory ( ) ) ;

addingForm . setItemDataSource ( pr j I tem ) ;

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”name” , ”model” }) ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {660 public void buttonCl ick ( ClickEvent event ) {

try {addingForm . commit ( ) ;

a p p l i c a t i o n . getCtr lQuest ion ( ) . c r e a t e ( qst ) ;

} catch ( SaveException e ) {}

}}) ;

p . addComponent ( addingForm ) ;

670 p . addComponent ( apply ) ;

}

public void q u e s t i o n n a i r e D e t a i l s ( ) {c t r lQ ue s t i o n = a p p l i c a t i o n . getCtr lQuest ion ( ) ;

f ina l Quest ionna i re qst = ( Quest ionna i re ) que s t i onna i r e sTab l e

. getValue ( ) ;

f ina l Panel p = new Panel ( ” Quest ionna i re d e t a i l s ” ) ;

p . s e tS i z eUnde f ined ( ) ;

680 f ina l Panel po = new Panel ( ” Operat ions ” ) ;

po . s e tS i z eUnde f ined ( ) ;

Hor izonta lLayout h = new Horizonta lLayout ( ) ;

472

Page 491: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

po . setContent (h) ;

Vert i ca lLayout vertL = new Vert i ca lLayout ( ) ;

vertL . addComponent (p) ;

vertL . addComponent ( po ) ;

quest ionGridL . removeComponent (1 , 0) ;

quest ionGridL . addComponent ( vertL , 1 , 0) ;

690 BeanItem<Quest ionnaire> prj I tem = quest ionna i reDataSource . getItem ( qst ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm . setFormFieldFactory (new Quest ionna i r eF i e ldFactory ( qst ) ) ;

modifyForm . setItemDataSource ( pr j I tem ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”name” , ”model” }) ) ;

700 Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {modifyForm . commit ( ) ;

c t r lQ ue s t i o n . update ( qst ) ;

p . getWindow ( ) . showNot i f i c a t i on ( ” Conf irmation ” , ”<br/>” ,

N o t i f i c a t i o n .TYPE TRAY NOTIFICATION) ;

que s t i onna i r e sTab l e . r eques tRepa intAl l ( ) ;

} catch ( SaveException e ) {p . getWindow ( ) . showNot i f i c a t i on ( ” Error ” ,

710 ”<br/>” + e . t oS t r i ng ( ) ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}}

}) ;

Button d i s ca rd = new Button ( ” Discard ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

modifyForm . d i s ca rd ( ) ;

}}) ;

720 Button btnQuest ionna i re = new Button ( ” Quest ions l i s t ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

c t r lQ ue s t i o n . v iewAl l ( qs t ) ;

}}) ;

p . addComponent ( modifyForm ) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

730 btnLayout . addComponent ( d i s ca rd ) ;

p . addComponent ( btnLayout ) ;

po . addComponent ( btnQuest ionna i re ) ;

}

public void q u e s t i o n n a i r e L i s t ( ) {c t r lQ ue s t i o n = a p p l i c a t i o n . getCtr lQuest ion ( ) ;

a p p l i c a t i o n . setArea ( ” L i s t a l l a c t i v e p r o j e c t s . . . ” ) ;

body . removeAllComponents ( ) ;

473

Page 492: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

Panel p = new Panel ( ”” ) ;

740 p . setWidth (95 , S i z e a b l e .UNITS PERCENTAGE) ;

quest ionGridL = new GridLayout (2 , 1) ;

quest ionGridL . se tSpac ing ( true ) ;

quest ionGridL . setMargin ( true ) ;

quest ionGridL . s e t S i z e F u l l ( ) ;

quest ionGridL . addComponent (p , 0 , 0) ;

body . addComponent ( quest ionGridL ) ;

body . setComponentAlignment ( questionGridL , Alignment .TOP LEFT) ;

que s t i onna i r e sTab l e = new Table ( ) ;

750 que s t i onna i r e sTab l e . s e t S e l e c t a b l e ( true ) ;

que s t i onna i r e sTab l e . setImmediate ( true ) ;

que s t i onna i r e sTab l e . addLis tener ( a p p l i c a t i o n . getCtr lQuest ion ( ) ) ;

L i s t<Quest ionnaire> datas = c t r l Q ue s t i o n . ge tL i s tDataQues t ionna i r e ( ) ;

i f ( datas . s i z e ( ) > 0) {quest ionna i reDataSource = new BeanItemContainer<Quest ionnaire >(

datas ) ;

que s t i onna i r e sTab l e . setContainerDataSource ( quest ionna i reDataSource ) ;

que s t i onna i r e sTab l e . setVis ib leColumns (new Object [ ] { ”name” ,

”model” }) ;

760 que s t i onna i r e sTab l e . setColumnHeaders (new St r ing [ ] {” Quest ionna i re Name” , ”UML Model” }) ;

que s t i onna i r e sTab l e . setColumnReorderingAllowed ( fa l se ) ;

que s t i onna i r e sTab l e . setColumnCollapsingAllowed ( fa l se ) ;

que s t i onna i r e sTab l e . setPageLength (10) ;

}p . addComponent ( que s t i onna i r e sTab l e ) ;

Button btnAddQuestion = new Button ( ”Add q u e s t i o n n a i r e ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

770 quest ionnaireAdd ( ) ;

}}) ;

p . addComponent ( btnAddQuestion ) ;

}

public void q u e s t i o n s L i s t ( ) {c t r lQ ue s t i o n = a p p l i c a t i o n . getCtr lQuest ion ( ) ;

a p p l i c a t i o n . setArea ( ” Pro j e c t ’ s que s t i on s . . . ” ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( ru le sL i s tWin ) ;

780 a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( rulesWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( answerWin ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( questionWin ) ;

body . removeAllComponents ( ) ;

Panel p = new Panel ( ”” ) ;

p . s e tS i z eUnde f ined ( ) ;

quest ionGridL = new GridLayout (2 , 3) ;

quest ionGridL . se tSpac ing ( true ) ;

quest ionGridL . setMargin ( true ) ;

quest ionGridL . s e tS i z eUnde f ined ( ) ;

790 quest ionGridL . addComponent (p , 0 , 0) ;

body . addComponent ( quest ionGridL ) ;

body . setComponentAlignment ( questionGridL , Alignment .TOP LEFT) ;

ques t ionsTab le = new Table ( ) ;

474

Page 493: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

quest ionsTab le . s e t S e l e c t a b l e ( true ) ;

ques t ionsTab le . setImmediate ( true ) ;

ques t ionsTab le . addLis tener ( c t r l Qu e s t i on . ge tQues t i onSe l e c t ed ( ) ) ;

ques t ionsTab le . addLis tener (new Property . ValueChangeListener ( ) {@Override

800 public void valueChange ( ValueChangeEvent event ) {r e f r e s h Q u e s t i o n L i s t ( ) ;

}}) ;

L i s t<Question> datas = c t r l Q ue s t i o n . getLi s tData ( ) ;

i f ( datas . s i z e ( ) > 0) {quest ionsDataSource = new BeanItemContainer<Question >(datas ) ;

ques t ionsTab le . setContainerDataSource ( quest ionsDataSource ) ;

ques t ionsTab le . setVis ib leColumns (new Object [ ] { ” ques t i on ” ,

” s i lDependent2 ” , ” c o n t e x t D e f i n i t i o n 2 ” }) ;

810 quest ionsTab le . setColumnHeaders (new St r ing [ ] { ” Question ” , ”SIL” ,

”CXT” }) ;

ques t ionsTab le . set ItemCapt ionPropertyId ( ” ques t i on Id ” ) ;

ques t ionsTab le . setColumnReorderingAllowed ( fa l se ) ;

ques t ionsTab le . setColumnCollapsingAllowed ( fa l se ) ;

ques t ionsTab le . setPageLength (10) ;

p . addComponent ( ques t ionsTab le ) ;

} else {p

. getWindow ( )

820 . showNot i f i c a t i on (

”No datas ” ,

”<br/>There aren ’ t any que s t i on s f o r t h i s p r o j e c t . ”

+ ”<br/><br/>You can add a new ques t i on by c l i c k i n g the button . ” ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}Button btnAddQuestion = new Button ( ”Add ques t i on ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

c t r lQ ue s t i o n . addQuestion ( ) ;

830 }}) ;

p . addComponent ( btnAddQuestion ) ;

Panel imgs = new Panel ( ”” ) ;

imgs . s e tS i z eUnde f ined ( ) ;

Embedded embedded1 = new Embedded( ”” , c t r lQ ue s t i o n . exportPiePackage ( ) ) ;

Embedded embedded2 = new Embedded( ”” , c t r lQ ue s t i o n . expor tP ieClas s ( ) ) ;

imgs . getContent ( ) . addComponent ( embedded1 ) ;

imgs . getContent ( ) . addComponent ( embedded2 ) ;

840 quest ionGridL . addComponent ( imgs , 1 , 0) ;

}

private void r e f r e s h Q u e s t i o n L i s t ( ) {i f ( quest ionGridL != null && quest ionsTable != null

&& c t r lQ ue s t i o n != null ) {List<Question> datas = c t r l Q ue s t i o n . getLi s tData ( ) ;

i f ( datas . s i z e ( ) > 0) {i f ( quest ionsDataSource != null

&& quest ionsDataSource . get I temIds ( ) != null ) {850 for ( Question d : quest ionsDataSource . get I temIds ( ) ) {

475

Page 494: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

c t r lQ ue s t i o n . r e f r e s h ( quest ionsDataSource . getItem (d)

. getBean ( ) ) ;

}}Object [ ] v i s ib leColumns = quest ionsTab le . getVis ib leColumns ( ) ;

ques t ionsTab le . setContainerDataSource ( quest ionsDataSource ) ;

ques t ionsTab le . setVis ib leColumns ( v i s ib leColumns ) ;

}quest ionsTab le . r eques tRepa intAl l ( ) ;

860 quest ionGridL . r eques tRepa intAl l ( ) ;

}}

}

D.6.14 Classe SubWindowManager.java

package i t . uniroma2 . norge . web ;

import java . u t i l . ArrayList ;

import com . vaadin . u i . Window ;

public class SubWindowManager {

private ArrayList<Window> subWindows ;

10 private TesiwebAppl icat ion a p p l i c a t i o n ;

public SubWindowManager ( Tes iwebAppl icat ion te s iwebApp l i ca t i on ) {this . a p p l i c a t i o n = tes iwebApp l i ca t i on ;

subWindows = new ArrayList<Window>() ;

}

public void addSubWindow(Window w) {20 subWindows . add (w) ;

a p p l i c a t i o n . getMainWindow ( ) . addWindow(w) ;

}

public void removeSubWindow (Window w) {i f (w != null && w. getParent ( ) != null )

( (Window) w. getParent ( ) ) . removeWindow(w) ;

}

public void removeAllSubWindow ( ) {30 for (Window w : subWindows ) {

i f (w != null && w. getParent ( ) != null )

( (Window) w. getParent ( ) ) . removeWindow(w) ;

}}

}

476

Page 495: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.6.15 Classe TesiwebApplication.java

package i t . uniroma2 . norge . web ;

import i t . uniroma2 . norge . c o n t r o l l e r . Ass ignmentsCtr l ;

import i t . uniroma2 . norge . c o n t r o l l e r . De fDe l i v e r ab l eCt r l ;

import i t . uniroma2 . norge . c o n t r o l l e r . D e l i v e r a b l e C t r l ;

import i t . uniroma2 . norge . c o n t r o l l e r . DocumentCtrl ;

import i t . uniroma2 . norge . c o n t r o l l e r . LoggedUser ;

import i t . uniroma2 . norge . c o n t r o l l e r . Organ izat ionCtr l ;

import i t . uniroma2 . norge . c o n t r o l l e r . AgreementCtrl ;

10 import i t . uniroma2 . norge . c o n t r o l l e r . F i l l o u t V a l i d a t i o n C t r l ;

import i t . uniroma2 . norge . c o n t r o l l e r . Que s t i onna i r e sCt r l ;

import i t . uniroma2 . norge . c o n t r o l l e r . UmlModelCtrl ;

import i t . uniroma2 . norge . c o n t r o l l e r . User sCtr l ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

import java . u t i l . ArrayList ;

import java . u t i l . L i s t ;

import javax . s e r v l e t . Serv l e tContext ;

20 import javax . s e r v l e t . http . HttpServ letRequest ;

import javax . s e r v l e t . http . HttpServletResponse ;

import com . vaadin . App l i ca t ion ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . data . Property . ValueChangeListener ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . s e r v i c e . Appl icat ionContext ;

import com . vaadin . t e rmina l . S i z e a b l e ;

import com . vaadin . t e rmina l . gwt . s e r v e r . Ht tpServ l e tReques tL i s t ene r ;

30 import com . vaadin . t e rmina l . gwt . s e r v e r . WebApplicationContext ;

import com . vaadin . u i . Alignment ;

import com . vaadin . u i . Button ;

import com . vaadin . u i . GridLayout ;

import com . vaadin . u i . Hor izonta lLayout ;

import com . vaadin . u i . Label ;

import com . vaadin . u i . Nat i v eSe l e c t ;

import com . vaadin . u i . Panel ;

import com . vaadin . u i . Ur iFragmentUt i l i ty ;

import com . vaadin . u i . Vert i ca lLayout ;

40 import com . vaadin . u i . Window ;

import com . vaadin . u i . Button . Cl ickEvent ;

import com . vaadin . u i . Button . C l i c k L i s t e n e r ;

import com . vaadin . u i . Window . N o t i f i c a t i o n ;

public class TesiwebAppl icat ion extends Appl i ca t ion implements

HttpServ l e tReques tL i s t ene r {

private stat ic f ina l long se r ia lVer s ionUID = 2099826500976990169L ;

50 private stat ic f ina l f loat BODYSIZE = 96 ;

private MyMenuBar menu ;

private Label t i t l e ;

477

Page 496: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private LoggedUser loggedUser ;

private MyLoginForm l o g i n ;

60 private Vert i ca lLayout menuLayout ;

private Horizonta lLayout areaLayout ;

private Vert i ca lLayout body ;

private Horizonta lLayout headerLayout ;

private Horizonta lLayout headerLogout ;

70 protected UsersCtr l c t r l U s e r s ;

protected AgreementCtrl c t r l P r j ;

protected Ques t i onna i r e sCt r l c t r l Q ue s t i o n ;

protected UmlModelCtrl ctrlUmlModel ;

protected AssignmentsCtr l c t r lAss ignment ;

80 private Ques t i onna i r e sCt r l c t r l R u l e ;

protected F i l l o u t V a l i d a t i o n C t r l c t r l Q u e s t i o n n a i r e ;

protected SubWindowManager subWindowManager ;

public DocumentCtrl ctrlDocument ;

public D e l i v e r a b l e C t r l c t r l D e l i v e r a b l e s ;

90 public UriFragmentUt i l i ty u r i f u ;

private De fDe l i v e r ab l eCt r l c t r l D e f D e l i v e r a b l e s ;

Organ i zat ionCtr l c t r l O r g a n i z a t i o n s ;

@Override

public void onRequestStart ( HttpServ letRequest request ,

HttpServletResponse re sponse ) {}

100@Override

public void onRequestEnd ( HttpServ letRequest request ,

HttpServletResponse re sponse ) {}

@Override

public void i n i t ( ) {Window mainWindow = new Window(

”Tool support ing agreement on ev idence − Ture l l a Emanuele / Davide

F a l e s s i ” ) ;

478

Page 497: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

110 setMainWindow (mainWindow) ;

setTheme ( ”mytheme” ) ;

u r i f u = new UriFragmentUt i l i ty ( ) ;

subWindowManager = new SubWindowManager ( this ) ;

body = new Vert i ca lLayout ( ) ;

menuLayout = new Vert i ca lLayout ( ) ;

areaLayout = new Horizonta lLayout ( ) ;

Vert i ca lLayout pageLayout = new Vert i ca lLayout ( ) ;

headerLayout = new Horizonta lLayout ( ) ;

120 Vert i ca lLayout bodyLayout = new Vert i ca lLayout ( ) ;

GridLayout menuPanel = new GridLayout (2 , 1) ;

headerLogout = new Horizonta lLayout ( ) ;

menuPanel . setWidth (99 , S i z e a b l e .UNITS PERCENTAGE) ;

pageLayout . addComponent ( bodyLayout ) ;

pageLayout . setComponentAlignment ( bodyLayout , Alignment .TOP CENTER) ;

bodyLayout . addComponent ( menuPanel ) ;

130 bodyLayout . setComponentAlignment ( menuPanel , Alignment .TOP CENTER) ;

bodyLayout . addComponent ( body ) ;

bodyLayout . setComponentAlignment ( body , Alignment .TOP CENTER) ;

headerLayout . setMargin ( false , true , false , true ) ;

headerLayout . setWidth (99 , S i z e a b l e .UNITS PERCENTAGE) ;

menuPanel . setMargin ( true ) ;

menuPanel . setWidth (99 , S i z e a b l e .UNITS PERCENTAGE) ;

setHead ( ) ;

140menuLayout . addComponent (new Label ( ”” ) ) ;

menuPanel . addComponent ( menuLayout , 0 , 0) ;

menuPanel . setComponentAlignment ( menuLayout , Alignment .MIDDLE LEFT) ;

menuPanel . addComponent ( areaLayout , 1 , 0) ;

menuPanel . setComponentAlignment ( areaLayout , Alignment .MIDDLE RIGHT) ;

menuPanel . setColumnExpandRatio (0 , 5 . 0 f ) ;

menuPanel . setColumnExpandRatio (1 , 1 . 0 f ) ;

getMainWindow ( ) . setContent ( pageLayout ) ;

150getMainWindow ( ) . addComponent ( u r i f u ) ;

c t r l U s e r s = new UsersCtr l ( this ) ;

c t r l P r j = new AgreementCtrl ( this ) ;

c t r lQ ue s t i o n = new Ques t i onna i r e sCt r l ( this ) ;

c t r l Q u e s t i o n n a i r e = new F i l l o u t V a l i d a t i o n C t r l ( this ) ;

ctrlUmlModel = new UmlModelCtrl ( this ) ;

c t r lAss ignment = new AssignmentsCtr l ( this ) ;

ctrlDocument = new DocumentCtrl ( this ) ;

160 c t r l D e l i v e r a b l e s = new D e l i v e r a b l e C t r l ( this ) ;

c t r l O r g a n i z a t i o n s = new Organ izat ionCtr l ( this ) ;

c t r l D e f D e l i v e r a b l e s = new De fDe l i v e r ab l eCt r l ( this ) ;

c t r l R u l e = c t r lQ ue s t i o n ;

setLogoutURL ( ”/tesiWebApp/” ) ;

479

Page 498: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

loggedUser = new LoggedUser ( this ) ;

loggedUser . s e s s i onLog in ( ) ;

}

170 public Serv le tContext ge tServ l e tCtx ( ) {Appl icat ionContext appl icCtx = getContext ( ) ;

Serv l e tContext s e rv l e tCtx = ( ( WebApplicationContext ) appl icCtx )

. ge tHttpSess ion ( ) . ge tServ l e tContext ( ) ;

return s e rv l e tCtx ;

}

public void showNot i f i c a t i on ( S t r ing s t r ) {this . showNot i f i c a t i on ( ”” + str , true ) ;

}180

public void showNot i f i c a t i on ( S t r ing s t r , boolean notInTray ) {int type ;

i f ( ! notInTray )

type = N o t i f i c a t i o n .TYPE TRAY NOTIFICATION;

else

type = N o t i f i c a t i o n .TYPE HUMANIZED MESSAGE;

getMainWindow ( ) . showNot i f i c a t i on ( s t r , type ) ;

}

190 public void setHead ( ) {headerLayout . removeAllComponents ( ) ;

t i t l e = new Label (

”Tool support ing Agreement on ev idence <br/> Emanuele Ture l l a ” ) ;

t i t l e . setContentMode ( Label .CONTENT XHTML) ;

headerLayout . addComponent ( headerLogout ) ;

headerLayout

. setComponentAlignment ( headerLogout , Alignment .MIDDLE RIGHT) ;

headerLogout . s e tS i z eUnde f ined ( ) ;

i f ( loggedUser != null && loggedUser . i sLogged ( ) ) {200 Button c loseButton = new Button ( ”Logout” ) ;

c loseButton . addLis tener (new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

l ogout ( ) ;

}}) ;

headerLogout . removeAllComponents ( ) ;

headerLogout . addComponent ( c loseButton ) ;

headerLogout . setComponentAlignment ( c loseButton ,

Alignment .MIDDLE RIGHT) ;

210 }}

void l ogout ( ) {( ( WebApplicationContext ) getContext ( ) ) . ge tHttpSess ion ( ) . i n v a l i d a t e ( ) ;

c l o s e ( ) ;

}

protected void setArea ( S t r ing s t r ) {areaLayout . removeAllComponents ( ) ;

220 Button b = new Button ( ”Logout” ) ;

b . addLis tener (new C l i c k L i s t e n e r ( ) {

480

Page 499: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Override

public void buttonCl ick ( ClickEvent event ) {TesiwebAppl icat ion . this . l ogout ( ) ;

}}) ;

Label w = new Label ( ”Welcome ” + loggedUser . getUserObj ( ) . getName ( )

230 + ” ! &nbsp;&nbsp;&nbsp;&nbsp ; ” , Label .CONTENT XHTML) ;

w. s e t S i z e F u l l ( ) ;

areaLayout . addComponent (w) ;

areaLayout . setComponentAlignment (w, Alignment .MIDDLE LEFT) ;

areaLayout . addComponent (b) ;

areaLayout . setComponentAlignment (b , Alignment .MIDDLE RIGHT) ;

}

private void setMenu ( ) {240 menuLayout . removeAllComponents ( ) ;

menu = new MyMenuBar( ) ;

menu . setMargin ( false , true , false , true ) ;

menu . r e f r e s h ( loggedUser , this ) ;

menuLayout . addComponent (menu) ;

menuLayout . setComponentAlignment (menu , Alignment .MIDDLE LEFT) ;

}

public void bui ldLoginLayout ( ) {body . removeAllComponents ( ) ;

250 Label l = new Label (

” Sa fe ty Evidence De l ive ry Agreement D e f i n i t i o n Tool” ) ;

l . setStyleName ( ” t i t o l o ” ) ;

f ina l Panel panel = new Panel ( ”User l og in ” ) ;

panel . setWidth ( S i z e a b l e . SIZE UNDEFINED, 0) ;

l o g i n = new MyLoginForm( loggedUser ) ;

l o g i n . setMargin ( true ) ;

body . addComponent ( l ) ;

body . setComponentAlignment ( l , Alignment .TOP CENTER) ;

body . addComponent ( l o g i n ) ;

260 body . setComponentAlignment ( log in , Alignment .TOP CENTER) ;

}

private Nat iveSe l e c t p r o j e c t L i s t ;

private Agreement MasterProject ;

public void buildMainLayout ( ) {setHead ( ) ;

setArea ( ”” ) ;

i f ( ( ( LoggedUser ) getUser ( ) ) . getUserObj ( ) . getUser ( ) . equa l s ( ”admin” ) )

270 setMenu ( ) ;

body . removeAllComponents ( ) ;

i f ( ( ( LoggedUser ) getUser ( ) ) . getUserObj ( ) . getUser ( ) . equa l s ( ”admin” ) ) {Panel p = new Panel ( ”Welcome ” + loggedUser . getUserObj ( ) . getName ( ) ) ;

p . setWidth (BODYSIZE, S i z e a b l e .UNITS PERCENTAGE) ;

body . addComponent (p) ;

body . setComponentAlignment (p , Alignment .TOP CENTER) ;

481

Page 500: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

Label l = new Label ( ” Please use the menu” ) ;

p . addComponent ( l ) ;

280 } else {Panel p2 = new Panel ( ”Agreements” ) ;

p r o j e c t L i s t = new Nat iveSe l e c t ( ” Please s e l e c t the agreement ” ) ;

L i s t<Agreement> datas = new ArrayList<Agreement>() ;

datas . addAll ( ( ( LoggedUser ) getUser ( ) ) . p ro j e c t sForRo l e ( ” s u p p l i e r ” ) ) ;

datas . addAll ( ( ( LoggedUser ) getUser ( ) ) . p ro j e c t sForRo l e ( ” c e r t i f i e r ” ) ) ;

i f ( datas . s i z e ( ) > 0) {BeanItemContainer<Agreement> ds = new BeanItemContainer<Agreement>(

datas ) ;

p r o j e c t L i s t . setContainerDataSource ( ds ) ;

290 p r o j e c t L i s t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

p r o j e c t L i s t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

p r o j e c t L i s t . setValue ( ”” ) ;

p r o j e c t L i s t . setImmediate ( true ) ;

p r o j e c t L i s t . addLi s tener (new ValueChangeListener ( ) {@Override

public void valueChange ( ValueChangeEvent event ) {setMenu ( ) ;

s e tMaste rPro j ec t ( ( Agreement ) p r o j e c t L i s t . getValue ( ) ) ;

300 c t r l Q u e s t i o n n a i r e . menuSelected ( MasterProject ) ;

}}) ;

p2 . addComponent ( p r o j e c t L i s t ) ;

p2 . setWidth (BODYSIZE, S i z e a b l e .UNITS PERCENTAGE) ;

body . addComponent ( p2 ) ;

body . setComponentAlignment ( p2 , Alignment .TOP CENTER) ;

}}

310 }

protected Vert i ca lLayout getBody ( ) {return body ;

}

public AgreementCtrl g e tCt r lP r j ( ) {return c t r l P r j ;

}

320 public Ques t i onna i r e sCt r l ge tCtr lQuest ion ( ) {return c t r lQ ue s t i o n ;

}

public UsersCtr l ge tCtr lUser ( ) {return c t r l U s e r s ;

}

public AssignmentsCtr l getCtr lAss ignment ( ) {return ctr lAss ignment ;

330 }

public UmlModelCtrl getCtrlUmlModel ( ) {return ctrlUmlModel ;

482

Page 501: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

public Ques t i onna i r e sCt r l getCtr lRule ( ) {return c t r l R u l e ;

}

340 public F i l l o u t V a l i d a t i o n C t r l g e tCt r lQues t i onna i r e ( ) {return c t r l Q u e s t i o n n a i r e ;

}

public SubWindowManager getSubWindowManager ( ) {return subWindowManager ;

}

public DocumentCtrl getCtrlDocument ( ) {return ctrlDocument ;

350 }

public D e l i v e r a b l e C t r l g e t C t r l D e l i v e r a b l e s ( ) {return c t r l D e l i v e r a b l e s ;

}

public De fDe l i v e r ab l eCt r l g e t C t r l D e f D e l i v e r a b l e s ( ) {return c t r l D e f D e l i v e r a b l e s ;

}

360 public Organ izat ionCtr l g e tCt r lOrgan i za t i on s ( ) {return c t r l O r g a n i z a t i o n s ;

}

public void s e tMaste rPro j ec t ( Agreement masterPro ject ) {MasterProject = masterPro ject ;

}

public Agreement getMasterPro ject ( ) {return MasterProject ;

370 }

}

D.6.16 Classe UserUI.java

package i t . uniroma2 . norge . web ;

import i t . uniroma2 . norge . c o n t r o l l e r . SaveException ;

import i t . uniroma2 . norge . c o n t r o l l e r . User sCtr l ;

import i t . uniroma2 . norge . model . jpa . User ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . UserFie ldFactory ;

import java . u t i l . Arrays ;

import java . u t i l . L i s t ;

10import com . vaadin . data . u t i l . BeanItem ;

483

Page 502: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . t e rmina l . S i z e a b l e ;

import com . vaadin . u i . Alignment ;

import com . vaadin . u i . Button ;

import com . vaadin . u i . Form ;

import com . vaadin . u i . GridLayout ;

import com . vaadin . u i . Hor izonta lLayout ;

import com . vaadin . u i . Panel ;

20 import com . vaadin . u i . Table ;

import com . vaadin . u i . Vert i ca lLayout ;

import com . vaadin . u i . Button . Cl ickEvent ;

public class UserUI {

private TesiwebAppl icat ion a p p l i c a t i o n ;

private UsersCtr l c t r l U s e r ;

30 private Vert i ca lLayout body ;

private GridLayout userGridL ;

private BeanItemContainer<User> usersDataSource ;

public Table usersTable ;

public UserUI ( Tes iwebAppl icat ion appl ) {this . a p p l i c a t i o n = appl ;

40 c t r l U s e r = a p p l i c a t i o n . ge tCtr lUser ( ) ;

body = a p p l i c a t i o n . getBody ( ) ;

}

public void u s e r L i s t A l l ( ) {c t r l U s e r = a p p l i c a t i o n . ge tCtr lUser ( ) ;

a p p l i c a t i o n . setArea ( ”” ) ;

body . removeAllComponents ( ) ;

Panel p = new Panel ( ”” ) ;

p . setWidth (95 , S i z e a b l e .UNITS PERCENTAGE) ;

50 userGridL = new GridLayout (2 , 1) ;

userGridL . se tSpac ing ( true ) ;

userGridL . setMargin ( true ) ;

userGridL . s e t S i z e F u l l ( ) ;

userGridL . addComponent (p , 0 , 0) ;

body . addComponent ( userGridL ) ;

body . setComponentAlignment ( userGridL , Alignment .TOP LEFT) ;

usersTable = new Table ( ) ;

usersTable . s e t S e l e c t a b l e ( true ) ;

60 usersTable . setImmediate ( true ) ;

usersTable . addLis tener ( c t r l U s e r ) ;

L i s t<User> datas = c t r l U s e r . getL is tData ( ) ;

i f ( datas . s i z e ( ) > 0) {usersDataSource = new BeanItemContainer<User>(datas ) ;

usersTable . setContainerDataSource ( usersDataSource ) ;

usersTable . se tVis ib leColumns (new Object [ ] { ” user ” , ”name” , ” o r g a n i z a t i on ”

}) ;

484

Page 503: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

usersTable . setColumnHeaders (new St r ing [ ] { ”Username” , ”Name” ,

” Organizat ion ” }) ;

usersTable . setRowHeaderMode ( Table .ROW HEADER MODE PROPERTY) ;

usersTable . setColumnReorderingAllowed ( true ) ;

70 usersTable . setColumnCollapsingAllowed ( true ) ;

usersTable . setPageLength (10) ;

}p . addComponent ( usersTable ) ;

Button btnAddQuestion = new Button ( ”Add new user ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

userAdd ( ) ;

}}) ;

80 p . addComponent ( btnAddQuestion ) ;

}

public void userAdd ( ) {c t r l U s e r = a p p l i c a t i o n . ge tCtr lUser ( ) ;

a p p l i c a t i o n . setArea ( ” Create a new user . . . ” ) ;

body . removeAllComponents ( ) ;

f ina l Panel p = new Panel ( ”” ) ;

p . s e tS i z eUnde f ined ( ) ;

body . addComponent (p) ;

90 body . setComponentAlignment (p , Alignment .TOP CENTER) ;

f ina l User user = new User ( ) ;

user . setName ( ”” ) ;

user . s e tUser ( ”” ) ;

user . setPassword ( ”” ) ;

user . setPasswordcheck ( ”” ) ;

BeanItem<User> userItem = new BeanItem<User>(user ) ;

f ina l Form addingForm = new Form ( ) ;

100 addingForm . setWriteThrough ( fa l se ) ;

addingForm . setInval idCommitted ( fa l se ) ;

addingForm . setFormFieldFactory (new

UserFie ldFactory ( a p p l i c a t i o n . g e tCt r lOrgan i za t i on s ( ) . g e tOrgan i za t i ons ( ) ) ) ;

addingForm . setItemDataSource ( userItem ) ;

addingForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”name” , ” user ” , ”password” , ” passwordcheck ” , ” o r g a n i z a t i o n ” }) ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {110 public void buttonCl ick ( ClickEvent event ) {

try {addingForm . commit ( ) ;

a p p l i c a t i o n . ge tCtr lUser ( ) . c r e a t e ( user ) ;

a p p l i c a t i o n . showNot i f i c a t i on ( ” Conf irmation ” ) ;

} catch ( SaveException e ) {a p p l i c a t i o n . showNot i f i c a t i on ( ” Error ” ) ;

}}

}) ;

120

485

Page 504: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

p . addComponent ( addingForm ) ;

p . addComponent ( apply ) ;

}

public void u s e r D e t a i l s ( ) {c t r l U s e r = a p p l i c a t i o n . ge tCtr lUser ( ) ;

f ina l User user = ( User ) usersTable . getValue ( ) ;

f ina l Panel p = new Panel ( ” D e t a i l s ” ) ;

130 p . s e tS i z eUnde f ined ( ) ;

Vert i ca lLayout vertL = new Vert i ca lLayout ( ) ;

vertL . addComponent (p) ;

userGridL . removeComponent (1 , 0) ;

userGridL . addComponent ( vertL , 1 , 0) ;

BeanItem<User> userItem = usersDataSource . getItem ( user ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

140 modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm . setFormFieldFactory (new UserFie ldFactory ( user ,

a p p l i c a t i o n . g e tCt r lOrgan i za t i on s ( ) . ge tOrgan i za t i ons ( ) ) ) ;

modifyForm . setItemDataSource ( userItem ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {”name” , ” user ” , ”password” , ” passwordcheck ” , ” o r g a n i z a t i o n ” }) ) ;

Button apply = new Button ( ”Save” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

try {modifyForm . commit ( ) ;

150 a p p l i c a t i o n . ge tCtr lUser ( ) . update ( user ) ;

a p p l i c a t i o n . showNot i f i c a t i on ( ” Conf irmation ” ) ;

usersTable . r eques tRepa intAl l ( ) ;

} catch ( SaveException e ) {a p p l i c a t i o n . showNot i f i c a t i on ( ” Error ” ) ;

}}

}) ;

Button d i s ca rd = new Button ( ” Discard ” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

160 modifyForm . d i s ca rd ( ) ;

}}) ;

p . addComponent ( modifyForm ) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent ( d i s ca rd ) ;

p . addComponent ( btnLayout ) ;

}170

}

486

Page 505: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.6.17 Classe ValidationUI.java

package i t . uniroma2 . norge . web ;

import i t . uniroma2 . norge . common . AnswerStatus ;

import i t . uniroma2 . norge . common . D e l i v e r a b l e S t a t u s ;

import i t . uniroma2 . norge . common . Quest ionStatus ;

import i t . uniroma2 . norge . c o n t r o l l e r . LoggedUser ;

import i t . uniroma2 . norge . c o n t r o l l e r . F i l l o u t V a l i d a t i o n C t r l ;

import i t . uniroma2 . norge . c o n t r o l l e r . F i l l o u t V a l i d a t i o n C t r l . MpackageRank ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

10 import i t . uniroma2 . norge . model . jpa . AnswerSet ;

import i t . uniroma2 . norge . model . jpa . AnswsetHistory ;

import i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e ;

import i t . uniroma2 . norge . model . jpa . De l ive rab l eContentHi s to ry ;

import i t . uniroma2 . norge . model . jpa . De l ive rab l eEv idence ;

import i t . uniroma2 . norge . model . jpa . Evidence ;

import i t . uniroma2 . norge . model . jpa . Mpackage ;

import i t . uniroma2 . norge . model . jpa . Question ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . AnswerHistoryFie ldFactory ;

import i t . uniroma2 . norge . web . f i e l d f a c t o r y . AnswerSetFie ldFactory ;

20 import i t . uniroma2 . norge . web . f i e l d f a c t o r y . De l ivContentHis toryFie ldFactory ;

import i t . uniroma2 . norge . web . support . EvidenceMapBean ;

import i t . uniroma2 . norge . web . support . Val idat ionBean ;

import java . t ex t . SimpleDateFormat ;

import java . u t i l . ArrayList ;

import java . u t i l . Arrays ;

import java . u t i l . C o l l e c t i o n s ;

import java . u t i l . Comparator ;

import java . u t i l . Date ;

30 import java . u t i l . HashMap ;

import java . u t i l . LinkedHashMap ;

import java . u t i l . L inkedLis t ;

import java . u t i l . L i s t ;

import com . vaadin . addon . t r e e t a b l e . TreeTable ;

import com . vaadin . data . Item ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . data . u t i l . BeanItem ;

40 import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . t e rmina l . S i z e a b l e ;

import com . vaadin . u i . Alignment ;

import com . vaadin . u i . Button ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . ComponentContainer ;

import com . vaadin . u i . Embedded ;

import com . vaadin . u i . Form ;

import com . vaadin . u i . GridLayout ;

import com . vaadin . u i . Hor izonta lLayout ;

50 import com . vaadin . u i . Label ;

import com . vaadin . u i . Link ;

import com . vaadin . u i . Nat i v eSe l e c t ;

import com . vaadin . u i . Panel ;

import com . vaadin . u i . Table ;

487

Page 506: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import com . vaadin . u i . Vert i ca lLayout ;

import com . vaadin . u i . Window ;

import com . vaadin . u i . Button . Cl ickEvent ;

import com . vaadin . u i . Button . C l i c k L i s t e n e r ;

import com . vaadin . u i . Table . ColumnGenerator ;

60 import com . vaadin . u i . Window . N o t i f i c a t i o n ;

public class Val idat ionUI {

private TesiwebAppl icat ion a p p l i c a t i o n ;

private F i l l o u t V a l i d a t i o n C t r l c t r l Q u e s t i o n n a i r e ;

private Vert i ca lLayout body ;

70 private GridLayout quest ionGridL ;

private BeanItemContainer<AnswerSet> quest ionsDataSource ;

public Table quest ionsTab le ;

public Table answersTable ;

public Table ru le sExc luTable ;

public Table rulesMultTable ;

public Nat iveSe l e c t p r o j e c t L i s t ;

80private Window qstDtlAnswering ;

public Nat iveSe l e c t packageLis t ;

private Window qstEvidMap ;

private St r ing de f in i t i onOfContex t = ” D e f i n i t i o n o f C o n t e x t ” ;

public Val idat ionUI ( Tes iwebAppl icat ion appl ) {90 this . a p p l i c a t i o n = appl ;

c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

body = a p p l i c a t i o n . getBody ( ) ;

}

public void p r o j e c t s L i s t ( ) {c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

LoggedUser user = ( LoggedUser ) a p p l i c a t i o n . getUser ( ) ;

a p p l i c a t i o n . setArea ( ”” ) ;

body . removeAllComponents ( ) ;

100 Panel p = new Panel ( ”Agreements” ) ;

p . s e tS i z eUnde f ined ( ) ;

quest ionGridL = new GridLayout (3 , 3) ;

quest ionGridL . se tSpac ing ( true ) ;

quest ionGridL . setMargin ( true ) ;

quest ionGridL . s e t S i z e F u l l ( ) ;

quest ionGridL . addComponent (p , 0 , 0) ;

body . addComponent ( quest ionGridL ) ;

body . setComponentAlignment ( questionGridL , Alignment .TOP LEFT) ;

110 p r o j e c t L i s t = new Nat iveSe l e c t ( ” Please s e l e c t the agreement ” ) ;

488

Page 507: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

BeanItemContainer<Agreement> ds = new BeanItemContainer<Agreement>(user

. p ro j e c t sForRo l e ( ” c e r t i f i e r ” ) ) ;

p r o j e c t L i s t . setContainerDataSource ( ds ) ;

p r o j e c t L i s t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

p r o j e c t L i s t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

p r o j e c t L i s t . setValue ( ”” ) ;

p r o j e c t L i s t . setImmediate ( true ) ;

p r o j e c t L i s t . addLis tener ( c t r l Q u e s t i o n n a i r e

120 . g e t P r o j e c t V a l i d a t i o n S e l e c t e d ( ) ) ;

p . addComponent ( p r o j e c t L i s t ) ;

}

public void packagesL i s t ( ) {c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

Vert i ca lLayout v l = new Vert i ca lLayout ( ) ;

v l . s e t S i z e F u l l ( ) ;

quest ionGridL . removeComponent (0 , 1) ;

130 quest ionGridL . addComponent ( vl , 0 , 1 , 2 , 1) ;

Panel pkg = new Panel ( ” Packages ” ) ;

pkg . s e t S i z e F u l l ( ) ;

quest ionGridL . removeComponent (2 , 0) ;

quest ionGridL . addComponent ( pkg , 2 , 0) ;

quest ionGridL . setComponentAlignment ( pkg , Alignment .TOP CENTER) ;

Li s t<MpackageRank> datas = c t r l Q u e s t i o n n a i r e . getListDataMpackage ( ) ;

140 packageLis t = new Nat iveSe l e c t ( ”” ) ;

LinkedList<Mpackage> datas2 = new LinkedList<Mpackage>() ;

for ( MpackageRank m : datas )

i f ( !m. getMpackage ( ) . getCanonicalName ( ) . conta in s (

de f in i t i onOfContex t ) )

datas2 . add (m. getMpackage ( ) ) ;

BeanItemContainer<Mpackage> ds = new BeanItemContainer<Mpackage>(datas2 ) ;

packageLis t . setContainerDataSource ( ds ) ;

packageLis t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

150 packageLis t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

packageLis t . setValue ( ” S e l e c t a package to view r e l a t e d que s t i on s ” ) ;

packageLis t . setImmediate ( true ) ;

packageLis t . addLis tener ( c t r l Q u e s t i o n n a i r e

. ge tPackageVa l idat ionSe l e c t ed ( ) ) ;

pkg . addComponent ( packageLis t ) ;

Panel p1 = new Panel ( ” Overa l l s t a t u s ” ) ;

p1 . s e tS i z eUnde f ined ( ) ;

160 p1 . setContent (new Horizonta lLayout ( ) ) ;

Embedded embedded1a = new Embedded( ”” , c t r l Q u e s t i o n n a i r e . exportPie1 ( ) ) ;

Embedded embedded2a = new Embedded( ”” , c t r l Q u e s t i o n n a i r e . exportPie2 ( ) ) ;

Embedded embedded3a = new Embedded( ”” , c t r l Q u e s t i o n n a i r e . exportPie3 ( ) ) ;

p1 . addComponent ( embedded1a ) ;

p1 . addComponent ( embedded2a ) ;

p1 . addComponent ( embedded3a ) ;

489

Page 508: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

v l . addComponent ( p1 ) ;

v l . setComponentAlignment ( p1 , Alignment .TOP CENTER) ;

i f ( datas != null && datas . s i z e ( ) > 0) {170 for ( f ina l MpackageRank pr : datas ) {

Panel p = new Panel ( pr . getMpackage ( ) . getCanonicalName ( )

+ ” ( p r i o r i t y ” + pr . getRank ( ) + ” ) ” ) ;

p . s e tS i z eUnde f ined ( ) ;

p . setContent (new Horizonta lLayout ( ) ) ;

Button embedded1 = new Button ( ) ;

embedded1 . s e t I c on ( c t r l Q u e s t i o n n a i r e . exportPieQPackage ( pr

. getMpackage ( ) ) ) ;

Button embedded2 = new Button ( ) ;

embedded2 . s e t I c on ( c t r l Q u e s t i o n n a i r e . exportPieAPackage ( pr

180 . getMpackage ( ) ) ) ;

Button embedded3 = new Button ( ) ;

embedded3 . s e t I c on ( c t r l Q u e s t i o n n a i r e . exportPieDPackage ( pr

. getMpackage ( ) ) ) ;

C l i c k L i s t e n e r c = new C l i c k L i s t e n e r ( ) {private stat ic f ina l long se r ia lVer s ionUID = 1L ;

@Override

public void buttonCl ick ( ClickEvent event ) {c t r l Q u e s t i o n n a i r e . packageSe l e c t edVa l ida t i on ( pr

190 . getMpackage ( ) ) ;

}} ;

embedded1 . addLis tener ( c ) ;

embedded2 . addLis tener ( c ) ;

embedded3 . addLis tener ( c ) ;

p . addComponent ( embedded1 ) ;

p . addComponent ( embedded2 ) ;

p . addComponent ( embedded3 ) ;

v l . addComponent (p) ;

200 v l . setComponentAlignment (p , Alignment .TOP CENTER) ;

}}

}

public void q u e s t i o n s L i s t ( ) {c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

Panel p = new Panel ( ”” ) ;

p . s e tS i z eUnde f ined ( ) ;

quest ionGridL . removeComponent (0 , 1) ;

210 quest ionGridL . addComponent (p , 0 , 1 , 2 , 1) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( qstDtlAnswering ) ;

ques t ionsTab le = new Table ( ) ;

ques t ionsTab le . s e t S e l e c t a b l e ( true ) ;

ques t ionsTab le . setImmediate ( true ) ;

L i s t<AnswerSet> datas = c t r l Q u e s t i o n n a i r e . getListDataAnswer ( ) ;

i f ( datas . s i z e ( ) > 0) {quest ionsDataSource = new BeanItemContainer<AnswerSet>(datas ) ;

ques t ionsTab le . setContainerDataSource ( quest ionsDataSource ) ;

220 quest ionsTab le . setColumnReorderingAllowed ( true ) ;

ques t ionsTab le . setColumnCollapsingAllowed ( fa l se ) ;

int x = 20 ;

490

Page 509: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

i f ( datas . s i z e ( ) < x )

x = datas . s i z e ( ) ;

ques t ionsTab le . s o r t (new Object [ ] { ” ranking ” } ,

new boolean [ ] { true }) ;

ques t ionsTab le . setPageLength ( x ) ;

ques t ionsTab le . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

ques t ionsTab le . s e t M u l t i S e l e c t ( fa l se ) ;

230 quest ionsTab le . addGeneratedColumn ( ”Agreement on Evidence ” ,

new Table . ColumnGenerator ( ) {public Component g e n e r a t e Ce l l ( Table source ,

Object itemId , Object columnId ) {Item item = quest ionsTab le . getItem ( itemId ) ;

f ina l I n t e g e r qid = ( I n t e g e r ) item . getItemProperty (

” answerSetId ” ) . getValue ( ) ;

Button b = new Button ( ” His tory ” ) ;

b . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

240 public void buttonCl ick ( ClickEvent event ) {r e f r e s h Q u e s t i o n L i s t ( ) ;

c t r l Q u e s t i o n n a i r e

. que s t i onVa l i da t i onH i s t o ry ( qid ) ;

}}) ;

Button b2 = new Button ( ” Proposal ” ) ;

b2 . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {250 r e f r e s h Q u e s t i o n L i s t ( ) ;

c t r l Q u e s t i o n n a i r e

. q u e s t i o n V a l i d a t i o n D e t a i l s ( qid ) ;

}}) ;

Hor izonta lLayout l = new Horizonta lLayout ( ) ;

l . addComponent (b) ;

l . addComponent ( b2 ) ;

return l ;

}260 }) ;

ques t ionsTab le . addGeneratedColumn ( ”Agreement on D e l i v e r a b l e s ” ,

new Table . ColumnGenerator ( ) {public Component g e n e r a t e Ce l l ( Table source ,

Object itemId , Object columnId ) {Item item = quest ionsTab le . getItem ( itemId ) ;

f ina l St r ing s t a t u s = ( St r ing ) item

. getItemProperty ( ” approvat ionStatusF ina l ” )

. getValue ( ) ;

i f ( s t a t u s == null

270 | | s t a t u s

. equa l s IgnoreCase ( Quest ionStatus .TO SPECIFY) )

return new Label ( ”” ) ;

f ina l I n t e g e r qid = ( I n t e g e r ) item . getItemProperty (

” answerSetId ” ) . getValue ( ) ;

Button b = new Button ( ” His tory ” ) ;

b . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {

491

Page 510: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

r e f r e s h Q u e s t i o n L i s t ( ) ;

280 c t r l Q u e s t i o n n a i r e

. que s t i onVa l ida t i onEv idenceHi s to ry ( qid ) ;

}}) ;

Button b2 = new Button ( ” Proposal ” ) ;

b2 . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {r e f r e s h Q u e s t i o n L i s t ( ) ;

c t r l Q u e s t i o n n a i r e

290 . ques t i onVa l idat ionEv idence ( qid ) ;

}}) ;

Hor izonta lLayout l = new Horizonta lLayout ( ) ;

i f ( item . getItemProperty ( ” ques t i on ” ) != null ) {f ina l Question q = ( Question ) item

. getItemProperty ( ” ques t i on ” ) . getValue ( ) ;

i f ( q . ge tRe la t i on ( ) == null ) {l . addComponent (b) ;

l . addComponent ( b2 ) ;

300 }}return l ;

}}) ;

i f ( datas . s i z e ( ) > 0) {quest ionsTab le

. setVis ib leColumns (new Object [ ] { ” ranking ” ,

” quest ionText ” , ” f i n a l S t a t u s ” ,

” approvat ionStatusF ina l ” ,

310 ”Agreement on Evidence ” ,

” de l ivApprovat ionStatus ” ,

”Agreement on D e l i v e r a b l e s ” }) ;

ques t ionsTab le . setColumnHeaders (new St r ing [ ] { ” P r i o r i t y ” ,

” Question ” , ” Fina l Status ” , ” Evidence Status ” ,

”Agreement on Evidence ” , ” Del iv . Status ” ,

”Agreement on D e l i v e r a b l e s ” }) ;

}Link exportZip = new Link ( ”Export ECORE ( diagram graph ) ” ,

320 c t r l Q u e s t i o n n a i r e . exportEcoreDiag ( ) ) ;

p . addComponent ( ques t ionsTab le ) ;

Hor izonta lLayout images = new Horizonta lLayout ( ) ;

Embedded embedded1 = new Embedded( ”” , c t r l Q u e s t i o n n a i r e

. exportPieQRefPackage ( ) ) ;

Embedded embedded2 = new Embedded( ”” , c t r l Q u e s t i o n n a i r e

. exportPieARefPackage ( ) ) ;

Embedded embedded3 = new Embedded( ”” , c t r l Q u e s t i o n n a i r e

. exportPieDRefPackage ( ) ) ;

images . addComponent ( embedded3 ) ;

330 images . addComponent ( embedded1 ) ;

images . addComponent ( embedded2 ) ;

p . addComponent ( images ) ;

ques t ionsTab le

492

Page 511: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

. s e t C e l l S ty l e Ge n e r a t o r (new Table . Ce l lS ty l eGenera to r ( ) {public St r ing g e t S t y l e ( Object itemId , Object propertyId ) {

i f ( propertyId == null | | i temId == null ) {return null ;

} else i f ( propertyId

340 . equa l s ( ” approvat ionStatusF ina l ” ) ) {Item item = quest ionsTab le . getItem ( itemId ) ;

f ina l St r ing s = ( St r ing ) item . getItemProperty (

” approvat ionStatusF ina l ” ) . getValue ( ) ;

i f ( s == null )

return null ;

else i f ( s . equa l s ( Quest ionStatus .TO SPECIFY) )

return ” orange ” ;

else i f ( s

. equa l s ( Quest ionStatus .YET TO ANALYZE) )

350 return ” ye l low ” ;

else i f ( s . equa l s ( Quest ionStatus .ACCEPTED) )

return ” green ” ;

else i f ( s . equa l s ( Quest ionStatus .REJECTED) )

return ” red ” ;

else i f ( s . equa l s ( Quest ionStatus .PART AGREED) )

return ” pink ” ;

} else i f ( propertyId . t oS t r i ng ( ) . conta in s (

” de l ivApprovat ionStatus ” ) ) {Item item = quest ionsTab le . getItem ( itemId ) ;

360 i f ( item . getItemProperty ( ” ques t i on ” ) != null ) {f ina l Question q = ( Question ) item

. getItemProperty ( ” ques t i on ” )

. getValue ( ) ;

i f ( q . ge tRe la t i on ( ) != null )

return null ;

}f ina l St r ing s = ( St r ing ) item . getItemProperty (

” de l ivApprovat ionStatus ” ) . getValue ( ) ;

i f ( s == null )

370 return ” orange ” ;

else i f ( s . equa l s ( Quest ionStatus .TO SPECIFY) )

return ” orange ” ;

else i f ( s

. equa l s ( Quest ionStatus .YET TO ANALYZE) )

return ” ye l low ” ;

else i f ( s . equa l s ( Quest ionStatus .ACCEPTED) )

return ” green ” ;

else i f ( s . equa l s ( Quest ionStatus .REJECTED) )

return ” red ” ;

380 else i f ( s . equa l s ( Quest ionStatus .PART AGREED) )

return ” pink ” ;

} else i f ( propertyId . t oS t r i ng ( ) . conta in s (

” f i n a l S t a t u s ” ) ) {Item item = quest ionsTab le . getItem ( itemId ) ;

S t r ing s1 = ( St r ing ) item . getItemProperty (

” approvat ionStatusF ina l ” ) . getValue ( ) ;

S t r ing s2 = ( St r ing ) item . getItemProperty (

” de l ivApprovat ionStatus ” ) . getValue ( ) ;

S t r ing s = Quest ionStatus . min ( s1 , s2 ) ;

390 i f ( s == null )

493

Page 512: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return ” orange ” ;

else i f ( s . equa l s ( Quest ionStatus .TO SPECIFY) )

return ” orange ” ;

else i f ( s

. equa l s ( Quest ionStatus .YET TO ANALYZE) )

return ” ye l low ” ;

else i f ( s . equa l s ( Quest ionStatus .ACCEPTED) )

return ” green ” ;

else i f ( s . equa l s ( Quest ionStatus .REJECTED) )

400 return ” red ” ;

else i f ( s . equa l s ( Quest ionStatus .PART AGREED) )

return ” pink ” ;

}return null ;

}}) ;

Panel p2 = new Panel ( ”” ) ;

p2 . s e tS i z eUnde f ined ( ) ;

410 p2 . addComponent ( exportZip ) ;

} else {p

. getWindow ( )

. showNot i f i c a t i on (

”No datas ” ,

”<br/>There aren ’ t any que s t i on s f o r t h i s p r o j e c t . ”

+ ”<br/><br/>You can add a new ques t i on by c l i c k i n g the button . ” ,

N o t i f i c a t i o n .TYPE WARNING MESSAGE) ;

}420 }

private void r e f r e s h Q u e s t i o n L i s t ( ) {i f ( quest ionGridL != null && quest ionsTable != null

&& c t r l Q u e s t i o n n a i r e != null ) {List<AnswerSet> datas = c t r l Q u e s t i o n n a i r e . getListDataAnswer ( ) ;

i f ( datas . s i z e ( ) > 0) {i f ( quest ionsDataSource != null

&& quest ionsDataSource . get I temIds ( ) != null ) {for ( AnswerSet d : quest ionsDataSource . get I temIds ( ) ) {

430 c t r l Q u e s t i o n n a i r e . r e f r e s h ( quest ionsDataSource

. getItem (d) . getBean ( ) ) ;

}}Object [ ] v i s ib leColumns = quest ionsTab le . getVis ib leColumns ( ) ;

ques t ionsTab le . setContainerDataSource ( quest ionsDataSource ) ;

ques t ionsTab le . setVis ib leColumns ( v i s ib leColumns ) ;

}quest ionsTab le . r eques tRepa intAl l ( ) ;

quest ionGridL . r eques tRepa intAl l ( ) ;

440 }}

public void q u e s t i o n D e t a i l s (boolean on lyHi s tory ) {c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

f ina l AnswerSet qst = c t r l Q u e s t i o n n a i r e . getReferenceAnswset ( ) ;

S t r ing t i t l e = ” Question Id : ” + qst . getQuest ion ( ) . getQuest ionId ( ) ;

494

Page 513: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

t i t l e = ” Val idate ques t i on ” ;

i f ( on lyHi s tory )

t i t l e = ” History ” ;

450 a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( qstDtlAnswering ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( qstEvidMap ) ;

qstDtlAnswering = new Window( t i t l e ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) qstDtlAnswering . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . setWidth (800 , S i z e a b l e . UNITS PIXELS) ;

f ina l AnswerSet re sponse = qst ;

i f ( ! on lyHi s tory ) {p . addComponent (new Label ( qs t . getQuest ion ( ) . getQuest ion ( ) ) ) ;

460 BeanItem<AnswerSet> a l t I t em = new BeanItem<AnswerSet>( r e sponse ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm . setFormFieldFactory (new AnswerSetFie ldFactory ( response ,

fa l se ) ) ;

modifyForm . setItemDataSource ( a l t I t em ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays . a s L i s t (new St r ing [ ] {” approvat ionStatus ” }) ) ;

i f ( re sponse . getQuest ion ( ) . getOpenQuestion ( ) != null

470 && response . getQuest ion ( ) . getOpenQuestion ( )

. equa l s IgnoreCase ( ” yes ” ) ) {i f ( re sponse . getOpenAnswer ( ) == null )

re sponse . setOpenAnswer ( ”” ) ;

p

. addComponent (new Label ( ”Answer : \n”

+ response . getOpenAnswer ( ) ,

Label .CONTENT PREFORMATTED) ) ;

p . addComponent ( modifyForm ) ;

}480 f ina l LinkedHashMap<Integer , ValidationBean> f i l l i n g s = new

LinkedHashMap<Integer , ValidationBean >() ;

i f ( re sponse . getAnswsetAnsws ( ) != null

&& response . getAnswsetAnsws ( ) . s i z e ( ) > 0) {f ina l TreeTable ansTable = new TreeTable ( ) ;

ansTable . setWidth (98 , S i z e a b l e .UNITS PERCENTAGE) ;

ansTable . s e t S e l e c t a b l e ( true ) ;

ansTable . setImmediate ( true ) ;

for ( Evidence a : r e sponse . getAnswsetAnsws ( ) ) {f ina l Validat ionBean f = new Validat ionBean ( a ) ;

f i l l i n g s . put ( f . getAnswerId ( ) , f ) ;

490 }BeanItemContainer<ValidationBean> ansDataSource = new

BeanItemContainer<ValidationBean >(

f i l l i n g s . va lue s ( ) ) ;

ansTable . setContainerDataSource ( ansDataSource ) ;

int f i r s t l e v e l = 0 ;

for ( Evidence a : r e sponse . getAnswsetAnsws ( ) ) {f ina l Validat ionBean tmpP = f i l l i n g s . get ( a

. getAlternat iveAnswer ( ) . getAnswerId ( ) ) ;

ansTable . setChi ldrenAl lowed (tmpP , fa l se ) ;

500 i f ( a . getSonAnswsetAnsws ( ) != null

495

Page 514: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

&& a . getSonAnswsetAnsws ( ) . s i z e ( ) > 0) {ansTable . setChi ldrenAl lowed (tmpP , true ) ;

f i r s t l e v e l ++;

for ( Evidence b : a . getSonAnswsetAnsws ( ) ) {Validat ionBean tmpC = f i l l i n g s . get (b

. getAlternat iveAnswer ( ) . getAnswerId ( ) ) ;

ansTable . se tParent (tmpC, tmpP) ;

ansTable . setChi ldrenAl lowed (tmpC, fa l se ) ;

System . out . p r i n t l n (tmpP . getAnswer ( ) + ” <− ”

510 + tmpC . getAnswer ( ) ) ;

tmpP . addChild (tmpC) ;

}} else {

i f ( a . getFatherAnswsetAnsws ( ) == null ) {System . out . p r i n t l n (tmpP . getAnswer ( )

+ ” non ha f i g l i ” ) ;

f i r s t l e v e l ++;

}}

520 }

ansTable . setVis ib leColumns (new Object [ ] { ”answer” , ” yesno ” ,

” approvat ion ” }) ;

ansTable . setColumnHeaders (new St r ing [ ] { ”Answer” , ”Y/N” ,

”Agree” }) ;

ansTable . set ItemCapt ionPropertyId ( ”answsetAnswId” ) ;

ansTable . setColumnReorderingAllowed ( fa l se ) ;

ansTable . setColumnCollapsingAllowed ( fa l se ) ;

530 int tmp = 10 ;

ansTable . setPageLength (tmp) ;

p . addComponent ( ansTable ) ;

p . setComponentAlignment ( ansTable , ” c en te r ” ) ;

}Button apply = new Button ( ”Save and c l o s e ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

modifyForm . commit ( ) ;

540 ArrayList<Evidence> r e s p o n s e l = new ArrayList<Evidence >() ;

for ( Val idat ionBean f : f i l l i n g s . va lue s ( ) ) {r e s p o n s e l . add ( f . getAnswsetAnswCommitted ( ) ) ;

}a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

qstDtlAnswering ) ;

showConfirmationComment ( r e sponse l , r e sponse ) ;

}}) ;

Button c l o s e = new Button ( ” Close without sav ing ” ,

550 new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

qstDtlAnswering ) ;

}}) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

496

Page 515: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent (new Label ( ” ” ,

Label .CONTENT PREFORMATTED) ) ;

560 btnLayout . addComponent ( c l o s e ) ;

p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

}f ina l List<AnswsetHistory> h i s t o r y = response . ge tAnswse tHi s to r i e s ( ) ;

i f ( h i s t o r y != null && h i s t o r y . s i z e ( ) > 0) {C o l l e c t i o n s . s o r t ( h i s to ry , new Comparator<AnswsetHistory >() {

@Override

public int compare ( AnswsetHistory o1 , AnswsetHistory o2 ) {i f ( o1 . getModtime ( ) . a f t e r ( o2 . getModtime ( ) ) )

570 return −1;

else i f ( o1 . getModtime ( ) . b e f o r e ( o2 . getModtime ( ) ) )

return −1;

return 0 ;

}}) ;

p . addComponent (new Label ( ” Status changes h i s t o r y ” ) ) ;

f ina l Table h i s tTab le = new Table ( ) {@Override

protected St r ing formatPropertyValue ( Object rowId ,

580 Object co l Id , Property property ) {Object v = property . getValue ( ) ;

i f ( v instanceof Date ) {Date dateValue = ( Date ) v ;

SimpleDateFormat df = new SimpleDateFormat (

”d MMM yyyy HH:mm: s s ” ) ;

return df . format ( dateValue ) ;

}return super . formatPropertyValue ( rowId , co l Id , property ) ;

}590 } ;

h i s tTab l e . setWidth (98 , S i z e a b l e .UNITS PERCENTAGE) ;

h i s tTab l e . s e t S e l e c t a b l e ( fa l se ) ;

h i s tTab l e . setImmediate ( fa l se ) ;

BeanItemContainer<AnswsetHistory> ansDataSource = new

BeanItemContainer<AnswsetHistory >(

h i s t o r y ) ;

h i s tTab l e . setContainerDataSource ( ansDataSource ) ;

h i s tTab l e . se tVis ib leColumns (new Object [ ] { ”modtime” , ” user ” ,

600 ” r o l e ” , ” ac t i on ” , ”comment” }) ;

h i s tTab l e . setColumnHeaders (new St r ing [ ] { ”Date” , ”User” , ”Role” ,

” Action ” , ”Comment” }) ;

h i s tTab l e . addGeneratedColumn ( ” ac t i on ” , new ColumnGenerator ( ) {public Component g e n e r a t e Ce l l ( Table source , Object itemId ,

Object columnId ) {St r ing html = ( ( AnswsetHistory ) itemId ) . getAct ion ( ) ;

html = html . r e p l a c e ( ”\n” , ”<br/>” ) ;

Label label = new Label ( html , Label .CONTENT XHTML) ;

label . setWidth ( ”15em” ) ;

610 return label ;

}

497

Page 516: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}) ;

h i s tTab l e . addGeneratedColumn ( ”comment” , new ColumnGenerator ( ) {public Component g e n e r a t e Ce l l ( Table source , Object itemId ,

Object columnId ) {St r ing html = ( ( AnswsetHistory ) itemId ) . getComment ( ) ;

html = html . r e p l a c e ( ”\n” , ”<br/>” ) ;

Label label = new Label ( html , Label .CONTENT XHTML) ;

label . setWidth ( ”15em” ) ;

620 return label ;

}}) ;

h i s tTab l e . setColumnReorderingAllowed ( fa l se ) ;

h i s tTab l e . setColumnCollapsingAllowed ( fa l se ) ;

int x = 3 ;

i f ( h i s t o r y . s i z e ( ) < x )

x = h i s t o r y . s i z e ( ) ;

h i s tTab l e . setPageLength ( x ) ;

p . addComponent ( h i s tTab le ) ;

630 }qstDtlAnswering . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( qstDtlAnswering ) ;

}

public void ques t i onDeta i l sEv idence (boolean onlyHistory ,

f ina l Evidence a2 ) {c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

f ina l AnswerSet qst = c t r l Q u e s t i o n n a i r e . getReferenceAnswset ( ) ;

f ina l List<Del ive rab l e> d e l i v s = c t r l Q u e s t i o n n a i r e

640 . g e t D e l i v e r a b l e s L i s t ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( qstEvidMap ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( qstDtlAnswering ) ;

S t r ing t i t l e = ” Question Id : ” + qst . getQuest ion ( ) . getQuest ionId ( ) ;

t i t l e = ” Evidence to d e l i v e r a b l e s mapping” ;

qstEvidMap = new Window( t i t l e ) ;

qstEvidMap . setWidth (870 , S i z e a b l e . UNITS PIXELS) ;

qstEvidMap . se tHe ight (600 , S i z e a b l e . UNITS PIXELS) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) qstEvidMap . getContent ( ) ;

p . setMargin ( true ) ;

650 p . se tSpac ing ( true ) ;

f ina l AnswerSet re sponse = qst ;

i f ( re sponse . getAnswsetAnsws ( ) != null

&& response . getAnswsetAnsws ( ) . s i z e ( ) > 0) {p . addComponent (new Label ( qs t . getQuest ion ( ) . getQuest ion ( ) ) ) ;

Panel pane l s = new Panel ( ” This i s a l i g h t Panel ” ) ;

pane l s . setCapt ion ( null ) ;

pane l s . setStyleName ( Panel . STYLE LIGHT) ;

ComponentContainer ansTableWrapWrap = pane l s . getContent ( ) ;

pane l s . s e t S i z e F u l l ( ) ;

660 p . addComponent ( pane l s ) ;

for ( f ina l Evidence a : r e sponse . getAnswsetAnsws ( ) ) {i f ( a . getResponse ( ) . equa l s IgnoreCase ( ” yes ” ) ) {

f ina l Vert i ca lLayout tv = new Vert i ca lLayout ( ) ;

f ina l Panel panel = new Panel ( ” This i s a l i g h t Panel ” ) ;

panel . setCapt ion ( null ) ;

panel . setStyleName ( Panel . STYLE LIGHT) ;

panel . s e tHe ight (1 , S i z e a b l e . UNITS PIXELS) ;

498

Page 517: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

panel . setWidth (99 , S i z e a b l e .UNITS PERCENTAGE) ;

panel . s e t S c r o l l a b l e ( true ) ;

670 ComponentContainer ansTableWrap = panel . getContent ( ) ;

f ina l Table t = new Table ( ) ;

Button b1 = new Button ( a . getAlternat iveAnswer ( ) . getAnswer ( ) ) ;

b1 . setWidth (99 , S i z e a b l e .UNITS PERCENTAGE) ;

b1 . addLis tener (new C l i c k L i s t e n e r ( ) {@Override

public void buttonCl ick ( ClickEvent event ) {i f ( panel . getHeight ( ) < 10) {

panel . s e tHe ight (250 , S i z e a b l e . UNITS PIXELS) ;

panel . s e t S c r o l l a b l e ( fa l se ) ;

680 } else {panel . s e tHe ight (0 , S i z e a b l e . UNITS PIXELS) ;

panel . s e t S c r o l l a b l e ( fa l se ) ;

}}

}) ;

LinkedList<Str ing> poss = new LinkedList<Str ing >() ;

poss . add ( AnswerStatus .PROPOSED) ;

poss . add ( AnswerStatus .ACCEPTED) ;

poss . add ( AnswerStatus .PART AGREED) ;

690 poss . add ( AnswerStatus .REJECTED) ;

f ina l Nat iveSe l e c t n = new Nat iveSe l e c t ( ) ;

n . s e tS i z eUnde f ined ( ) ;

n . setCapt ion ( null ) ;

n . setNewItemsAllowed ( fa l se ) ;

n . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

f ina l BeanItemContainer<Str ing> ds2 = new BeanItemContainer<Str ing >(

poss ) ;

n . setContainerDataSource ( ds2 ) ;

i f ( a . getApprovat ionDel ivStatus ( ) != null )

700 n . setValue ( a . getApprovat ionDel ivStatus ( ) ) ;

else

n . setValue ( poss . get (0 ) ) ;

n . addLis tener (new Property . ValueChangeListener ( ) {@Override

public void valueChange ( ValueChangeEvent event ) {Object v = n . getValue ( ) ;

i f ( v != null ) {a . se tApprovat ionDe l ivStatus ( v . t oS t r i ng ( ) ) ;

showConfirmationCommentDeliverable ( a ) ;

710 }}

}) ;

n . setImmediate ( true ) ;

Hor izonta lLayout l = new Horizonta lLayout ( ) ;

l . setWidth (99 , S i z e a b l e .UNITS PERCENTAGE) ;

l . addComponent ( b1 ) ;

l . setExpandRatio ( b1 , 1 . 0 f ) ;

l . addComponent (new Label ( ”Agree : ” ) ) ;

l . addComponent (n) ;

720 ansTableWrap . addComponent ( tv ) ;

ansTableWrapWrap . addComponent ( l ) ;

ansTableWrapWrap . addComponent ( panel ) ;

i f ( ! on lyHi s tory ) {

499

Page 518: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

{f ina l HashMap<Del iverab leEvidence , EvidenceMapBean> f i l l i n g s = new

HashMap<Del iverab leEvidence , EvidenceMapBean>() ;

ArrayList<EvidenceMapBean> datas = new ArrayList<EvidenceMapBean>() ;

for ( D e l i v e r a b l e d : d e l i v s ) {Del ive rab l eEv idence de = c t r l Q u e s t i o n n a i r e

. g e tDe l i v e rab l eEv idence (a , d) ;

730 i f ( de . ge t Inc luded ( ) ) {f ina l EvidenceMapBean f = new EvidenceMapBean (

de ) ;

f i l l i n g s . put ( f . getDelEvid ( ) , f ) ;

datas . add ( f ) ;

f . getYesno ( ) . setImmediate ( true ) ;

}}i f ( datas . s i z e ( ) > 0) {

BeanItemContainer<EvidenceMapBean> ds = new

BeanItemContainer<EvidenceMapBean>(

740 datas ) ;

t . setContainerDataSource ( ds ) ;

t . se tVis ib leColumns (new Object [ ] {” d e l i v e r a b l e ” , ” addInfo ” }) ;

t . setColumnHeaders (new St r ing [ ] {” D e l i v e r a b l e ” , ”Add . In f o . ” }) ;

t

. s e t C e l l S ty l e Ge n e ra t o r (new Table . Ce l lS ty l eGenera to r ( ) {public St r ing g e t S t y l e (

Object itemId ,

750 Object propertyId ) {i f ( propertyId == null

| | i temId == null ) {return null ;

} else i f ( propertyId

. equa l s ( ” agreementStatus ” ) ) {Item item = t

. getItem ( itemId ) ;

f ina l St r ing s = ( St r ing ) item

. getItemProperty (

760 ” agreementStatus ” )

. getValue ( ) ;

i f ( s == null )

return null ;

else i f ( s

. equa l s ( D e l i v e r a b l e S t a t u s .PROPOSED) )

return ” ye l low ” ;

else i f ( s

. equa l s ( D e l i v e r a b l e S t a t u s .ACCEPTED) )

return ” green ” ;

770 else i f ( s

. equa l s ( D e l i v e r a b l e S t a t u s .REJECTED) )

return ” red ” ;

else i f ( s

. equa l s ( D e l i v e r a b l e S t a t u s .PART AGREED) )

return ” pink ” ;

} else i f ( propertyId

. t oS t r i ng ( ) . conta in s (

500

Page 519: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

” Del iv . Status ” ) ) {Item item = quest ionsTab le

780 . getItem ( itemId ) ;

f ina l St r ing s = ( St r ing ) item

. getItemProperty (

” de l ivApprovat ionStatus ” )

. getValue ( ) ;

i f ( s == null )

return ” ye l low ” ;

else i f ( s

. equa l s ( AnswerStatus .PROPOSED) )

return ” ye l low ” ;

790 else i f ( s

. equa l s ( AnswerStatus .ACCEPTED) )

return ” green ” ;

else i f ( s

. equa l s ( AnswerStatus .REJECTED) )

return ” red ” ;

else i f ( s

. equa l s ( AnswerStatus .PART AGREED) )

return ” pink ” ;

}800 return null ;

}}) ;

t . setColumnReorderingAllowed ( fa l se ) ;

t . setColumnCollapsingAllowed ( fa l se ) ;

int x = datas . s i z e ( ) ;

t . setPageLength ( x < 6 ? x : 6) ;

t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

t . s e t M u l t i S e l e c t ( fa l se ) ;

t . s e t S i z e F u l l ( ) ;

810 }}i f ( a2 != null

&& a . getAnswsetAnswId ( ) == a2

. getAnswsetAnswId ( ) )

panel . s e tHe ight (250 , S i z e a b l e . UNITS PIXELS) ;

tv . addComponent ( t ) ;

}f ina l List<Del iverab leContentHis tory> h i s t o r y = a

. getAnswsetAnswDel ivHistor ies ( ) ;

820 i f ( h i s t o r y != null && h i s t o r y . s i z e ( ) > 0) {C o l l e c t i o n s

. s o r t (

h i s to ry ,

new Comparator<Del iverab leContentHis tory >() {@Override

public int compare (

De l ive rab l eContentHi s to ry o1 ,

De l ive rab l eContentHi s to ry o2 ) {i f ( o1 . getModtime ( ) . a f t e r (

830 o2 . getModtime ( ) ) )

return −1;

else i f ( o1

. getModtime ( )

501

Page 520: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

. b e f o r e ( o2 . getModtime ( ) ) )

return 1 ;

return 0 ;

}}) ;

f ina l Table h i s tTab l e = new Table ( ) {840 @Override

protected St r ing formatPropertyValue ( Object rowId ,

Object co l Id , Property property ) {Object v = property . getValue ( ) ;

i f ( v instanceof Date ) {Date dateValue = ( Date ) v ;

SimpleDateFormat df = new SimpleDateFormat (

”d MMM yyyy HH:mm: s s ” ) ;

return df . format ( dateValue ) ;

}850 return super . formatPropertyValue ( rowId , co l Id ,

property ) ;

}} ;

h i s tTab l e . setWidth (98 , S i z e a b l e .UNITS PERCENTAGE) ;

h i s tTab l e . s e t S e l e c t a b l e ( fa l se ) ;

h i s tTab l e . setImmediate ( fa l se ) ;

BeanItemContainer<Del iverab leContentHis tory> ansDataSource = new

BeanItemContainer<Del iverab leContentHis tory >(

h i s t o r y ) ;

h i s tTab l e . setContainerDataSource ( ansDataSource ) ;

860h i s tTab l e . se tVis ib leColumns (new Object [ ] { ”modtime” ,

” user ” , ” r o l e ” , ” ac t i on ” , ”comment” }) ;

h i s tTab l e . setColumnHeaders (new St r ing [ ] { ”Date” ,

”User” , ”Role” , ” Action ” , ”Comment” }) ;

h i s tTab l e . addGeneratedColumn ( ” ac t i on ” ,

new ColumnGenerator ( ) {public Component g e n e r a t e C e l l ( Table source ,

Object itemId , Object columnId ) {870 St r ing html = ( ( De l ive rab l eContentHi s to ry ) itemId )

. getAct ion ( ) ;

html = html . r e p l a c e ( ”\n” , ”<br/>” ) ;

Label label = new Label ( html ,

Label .CONTENT XHTML) ;

label . setWidth ( ”15em” ) ;

return label ;

}}) ;

h i s tTab l e . addGeneratedColumn ( ”comment” ,

880 new ColumnGenerator ( ) {public Component g e n e r a t e C e l l ( Table source ,

Object itemId , Object columnId ) {St r ing html = ( ( De l ive rab l eContentHi s to ry ) itemId )

. getComment ( ) ;

html = html . r e p l a c e ( ”\n” , ”<br/>” ) ;

Label label = new Label ( html ,

Label .CONTENT XHTML) ;

label . setWidth ( ”15em” ) ;

502

Page 521: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return label ;

890 }}) ;

h i s tTab l e . setColumnReorderingAllowed ( fa l se ) ;

h i s tTab l e . setColumnCollapsingAllowed ( fa l se ) ;

int x = 3 ;

i f ( h i s t o r y . s i z e ( ) < x )

x = h i s t o r y . s i z e ( ) ;

h i s tTab l e . setPageLength ( x ) ;

tv . addComponent (new Label ( ”” ,

Label .CONTENT PREFORMATTED) ) ;

900 tv . addComponent (new Label ( ” Status changes h i s t o r y ” ) ) ;

tv . addComponent ( h i s tTab le ) ;

} else {tv . addComponent (new Label ( ”” ,

Label .CONTENT PREFORMATTED) ) ;

tv . addComponent (new Label ( ”No h i s t o r y a v a i l a b l e ” ) ) ;

}i f ( on lyHi s tory ) {

panel . s e tHe ight (250 , S i z e a b l e . UNITS PIXELS) ;

}910 }

}}qstEvidMap . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( qstEvidMap ) ;

}

protected void showConfirmationComment (

f ina l ArrayList<Evidence> r e sponse l , f ina l AnswerSet re sponse ) {c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

920 a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( qstDtlAnswering ) ;

qstDtlAnswering = new Window( ”Comment your changes ” ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) qstDtlAnswering . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

f ina l AnswsetHistory h i s t = new AnswsetHistory ( ) ;

h i s t . setComment ( ”” ) ;

h i s t . s e tRo le ( ” C e r t i f i e r ” ) ;

930 BeanItem<AnswsetHistory> a l t I t em = new BeanItem<AnswsetHistory >( h i s t ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm . setFormFieldFactory (new AnswerHistoryFie ldFactory ( h i s t ) ) ;

modifyForm . setItemDataSource ( a l t I t em ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays

. a s L i s t (new St r ing [ ] { ”comment” }) ) ;

p

940 . addComponent (new Label (

” Please exp la in the reason o f answer ’ s change” ) ) ;

p . addComponent ( modifyForm ) ;

Button apply = new Button ( ”Save and c l o s e ” , new Button . C l i c k L i s t e n e r ( ) {

503

Page 522: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void buttonCl ick ( ClickEvent event ) {modifyForm . commit ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

qstDtlAnswering ) ;

c t r l Q u e s t i o n n a i r e . saveApprovation ( r e sponse l , response , h i s t ) ;

950 }}) ;

Button c l o s e = new Button ( ” Close without sav ing ” ,

new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

qstDtlAnswering ) ;

}}) ;

960 Horizonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

btnLayout . addComponent ( c l o s e ) ;

p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

qstDtlAnswering . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( qstDtlAnswering ) ;

970 }

protected void showConfirmationCommentDeliverable ( f ina l Evidence a ) {c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( qstDtlAnswering ) ;

qstDtlAnswering = new Window( ”Comment your changes ” ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) qstDtlAnswering . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

980f ina l Del ive rab l eContentHi s to ry h i s t = new Del ive rab l eContentHi s to ry ( ) ;

h i s t . setComment ( ”” ) ;

h i s t . s e tRo le ( ” C e r t i f i e r ” ) ;

BeanItem<Del iverab leContentHis tory> a l t I t em = new

BeanItem<Del iverab leContentHis tory >(

h i s t ) ;

f ina l Form modifyForm = new Form ( ) ;

modifyForm . setWriteThrough ( fa l se ) ;

modifyForm . setInval idCommitted ( fa l se ) ;

modifyForm

990 . setFormFieldFactory (new Del ivContentHis toryFie ldFactory ( h i s t ) ) ;

modifyForm . setItemDataSource ( a l t I t em ) ;

modifyForm . s e t V i s i b l e I t e m P r o p e r t i e s ( Arrays

. a s L i s t (new St r ing [ ] { ”comment” }) ) ;

p

. addComponent (new Label (

” Please exp la in the reason o f answer ’ s change” ) ) ;

p . addComponent ( modifyForm ) ;

Button apply = new Button ( ”Save and c l o s e ” , new Button . C l i c k L i s t e n e r ( ) {

504

Page 523: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

1000 public void buttonCl ick ( ClickEvent event ) {modifyForm . commit ( ) ;

c t r l Q u e s t i o n n a i r e . saveDel iverablesMappingApprov ( a , h i s t ) ;

i f ( qstDtlAnswering != null )

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

qstDtlAnswering ) ;

}}) ;

Button c l o s e = new Button ( ” Close without sav ing ” ,

new Button . C l i c k L i s t e n e r ( ) {1010 public void buttonCl ick ( ClickEvent event ) {

a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow (

qstDtlAnswering ) ;

}}) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

btnLayout . addComponent ( c l o s e ) ;

1020 p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

qstDtlAnswering . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( qstDtlAnswering ) ;

}

public void showConfirmationQuestion ( ) {c t r l Q u e s t i o n n a i r e = a p p l i c a t i o n . g e tCt r lQues t i onna i r e ( ) ;

1030 a p p l i c a t i o n . getSubWindowManager ( ) . removeSubWindow ( qstDtlAnswering ) ;

qstDtlAnswering = new Window( ” Question agreement ” ) ;

Vert i ca lLayout p = ( Vert i ca lLayout ) qstDtlAnswering . getContent ( ) ;

p . setMargin ( true ) ;

p . s e tSpac ing ( true ) ;

p . s e tS i z eUnde f ined ( ) ;

p . addComponent (new Label ( ” Al l a l t e r n a t i v e s proposed by the s u p p l i e r ”

+ ” were accepted :\n”

+ ”would you l i k e to approve the e n t i r e ques t i on ?” ,

1040 Label .CONTENT PREFORMATTED) ) ;

Button apply = new Button ( ”Agreed” , new Button . C l i c k L i s t e n e r ( ) {public void buttonCl ick ( ClickEvent event ) {

c t r l Q u e s t i o n n a i r e

. saveFinalApprovat ion ( F i l l o u t V a l i d a t i o n C t r l . f ina lApprovStatus .AGREED) ;

}}) ;

Button p a r t i a l = new Button ( ” P a r t i a l l y agreed ” ,

new Button . C l i c k L i s t e n e r ( ) {1050 public void buttonCl ick ( ClickEvent event ) {

c t r l Q u e s t i o n n a i r e

. saveFinalApprovat ion ( F i l l o u t V a l i d a t i o n C t r l . f ina lApprovStatus .PART AGREED) ;

}}) ;

Button c l o s e = new Button ( ” Disagreed ” , new Button . C l i c k L i s t e n e r ( ) {

505

Page 524: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void buttonCl ick ( ClickEvent event ) {c t r l Q u e s t i o n n a i r e

. saveFinalApprovat ion ( F i l l o u t V a l i d a t i o n C t r l . f ina lApprovStatus .DISAGREED) ;

}1060 }) ;

Hor izonta lLayout btnLayout = new Horizonta lLayout ( ) ;

btnLayout . addComponent ( apply ) ;

btnLayout . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

btnLayout . addComponent ( p a r t i a l ) ;

btnLayout . addComponent (new Label ( ” ” , Label .CONTENT PREFORMATTED) ) ;

btnLayout . addComponent ( c l o s e ) ;

p . addComponent ( btnLayout ) ;

p . setComponentAlignment ( btnLayout , ” c en te r bottom” ) ;

1070qstDtlAnswering . c en t e r ( ) ;

a p p l i c a t i o n . getSubWindowManager ( ) . addSubWindow( qstDtlAnswering ) ;

}

public void q u e s t i o n D e t a i l s H i s t o r y ( ) {q u e s t i o n D e t a i l s ( true ) ;

}

1080 public void que s t i onDeta i l sEv idenceH i s to ry ( ) {ques t i onDeta i l sEv idence ( true , null ) ;

}}

D.7 Package it.uniroma2.norge.web.fieldfactory

D.7.1 Classe AgreementFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . QuestionnaireManager ;

import i t . uniroma2 . norge . model . jpa . Organizat ion ;

import i t . uniroma2 . norge . model . jpa . Agreement ;

import i t . uniroma2 . norge . model . jpa . Quest ionna i re ;

import java . u t i l . L i s t ;

10 import com . vaadin . data . Item ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . data . v a l i d a t o r . St r ingLengthVal idator ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

import com . vaadin . u i . Nat i v eSe l e c t ;

import com . vaadin . u i . TextFie ld ;

506

Page 525: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

20 public class AgreementFieldFactory extends Defau l tF i e ldFactory implements

FormFieldFactory {

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”12em” ;

private Agreement datasource ;

private List<Organizat ion> orgs ;

public AgreementFieldFactory ( Lis t<Organizat ion> orgs ) {30 datasource = null ;

this . o rgs = orgs ;

}

public AgreementFieldFactory ( Agreement prj , L i s t<Organizat ion> orgs ) {datasource = pr j ;

this . o rgs = orgs ;

}

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {40 Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

f ina l Nat iveSe l e c t model = new Nat iveSe l e c t ( ” Quest ionna i re ” ) ;

i f ( ”name” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ”Agreement name” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r the name o f the new agreement ” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

t f . addVal idator (new Str ingLengthVal idator (

”Name must be 1−255 c h a r a c t e r s ” , 1 , 255 , fa l se ) ) ;

50 i f ( datasource != null )

t f . setValue ( datasource . getName ( ) ) ;

return t f ;

} else i f ( ” q u e s t i o n n a i r e ” . equa l s ( propertyId ) ) {QuestionnaireManager c t rQue s t i onna i r e = new QuestionnaireManager ( ) ;

BeanItemContainer<Quest ionnaire> ds = new BeanItemContainer<Quest ionnaire >(

c t rQue s t i onna i r e . v iewAl l ( ) ) ;

model . setContainerDataSource ( ds ) ;

model . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

model . se tRequi red ( true ) ;

60 model

. s e tRequ i redError ( ” I t ’ s nece s sa ry to s p e c i f y the q u e s t i o n n a i r e

a s s o c i a t e d to t h i s p r o j e c t ” ) ;

i f ( datasource != null ) {model . s e l e c t ( datasource . ge tQues t i onna i r e ( ) ) ;

model . setValue ( datasource . ge tQues t i onna i r e ( ) ) ;

}return model ;

} else i f ( ” o r g a n i z a t i o n S u p p l i e r ” . equa l s ( propertyId ) ) {Nat iveSe l e c t n s e l = new Nat iveSe l e c t ( ) ;

n s e l . setCapt ion ( ” Supp l i e r ” ) ;

70 BeanItemContainer<Organizat ion> ds = new BeanItemContainer<Organizat ion >(

orgs ) ;

n s e l . setContainerDataSource ( ds ) ;

n s e l . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

n s e l . se tRequi red ( true ) ;

507

Page 526: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

i f ( datasource != null ) {n s e l . s e l e c t ( datasource . g e tOrgan i za t i onSupp l i e r ( ) ) ;

n s e l . setValue ( datasource . g e tOrgan i za t i onSupp l i e r ( ) ) ;

}return n s e l ;

80 } else i f ( ” o r g a n i z a t i o n C e r t i f i e r ” . equa l s ( propertyId ) ) {Nat iveSe l e c t n s e l = new Nat iveSe l e c t ( ) ;

n s e l . setCapt ion ( ” C e r t i f i e r ” ) ;

BeanItemContainer<Organizat ion> ds = new BeanItemContainer<Organizat ion >(

orgs ) ;

n s e l . setContainerDataSource ( ds ) ;

n s e l . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

n s e l . se tRequi red ( true ) ;

i f ( datasource != null ) {n s e l . s e l e c t ( datasource . g e t O r g a n i z a t i o n C e r t i f i e r ( ) ) ;

90 n s e l . setValue ( datasource . g e t O r g a n i z a t i o n C e r t i f i e r ( ) ) ;

}return n s e l ;

}return f ;

}

}

D.7.2 Classe AnswerFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . jpa . Alternat iveAnswer ;

import i t . uniroma2 . norge . model . jpa . Alternat iveAnswer . S i l L e v e l s ;

import java . u t i l . L inkedLis t ;

import java . u t i l . L i s t ;

import com . vaadin . data . Item ;

10 import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . data . v a l i d a t o r . St r ingLengthVal idator ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

import com . vaadin . u i . Nat i v eSe l e c t ;

import com . vaadin . u i . TextFie ld ;

public class AnswerFieldFactory extends Defau l tF i e ldFactory implements

20 FormFieldFactory {

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”12em” ;

private Alternat iveAnswer datasource ;

private List<AlternativeAnswer> a l t ;

public AnswerFieldFactory ( Lis t<AlternativeAnswer> datas ) {

508

Page 527: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

datasource = null ;

30 a l t = datas ;

}

public AnswerFieldFactory ( Alternat iveAnswer ans ,

L i s t<AlternativeAnswer> datas ) {datasource = ans ;

a l t = datas ;

}

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {40 Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

i f ( ”answer” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ”Answer” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r the answer” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

t f . addVal idator (new Str ingLengthVal idator (

”Answare must be 1−255 c h a r a c t e r s ” , 1 , 255 , fa l se ) ) ;

i f ( datasource != null )

50 t f . setValue ( datasource . getAnswer ( ) ) ;

return t f ;

} else i f ( ”answerCode” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ”Answer code ” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r the answer code ” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

t f . addVal idator (new Str ingLengthVal idator (

”Code must be 1−255 c h a r a c t e r s ” , 1 , 255 , fa l se ) ) ;

60 i f ( datasource != null )

t f . setValue ( datasource . getAnswerCode ( ) ) ;

return t f ;

} else i f ( ” s i l M i n L e v e l S t r i n g ” . equa l s ( propertyId ) ) {LinkedList<Str ing> poss = new LinkedList<Str ing >() ;

poss . add ( S i l L e v e l s .ALWAYS) ;

poss . add ( S i l L e v e l s . L1) ;

poss . add ( S i l L e v e l s . L2) ;

poss . add ( S i l L e v e l s . L3) ;

poss . add ( S i l L e v e l s . L4) ;

70 poss . add ( S i l L e v e l s .NEVER) ;

Nat iv eSe l e c t c = new Nat iveSe l e c t ( ) ;

c . setWidth (COMMON FIELD WIDTH) ;

c . setCapt ion ( ”Minimum SIL : ” ) ;

c . s e t D e s c r i p t i o n ( ” This answer w i l l be high r equ i r ed only ”

+ ” i f SIL i s equal or g r e a t e r the s p e c i f i e d value ” ) ;

c . setNewItemsAllowed ( fa l se ) ;

c . s e tNu l l S e l e c t i onA l l owed ( true ) ;

i f ( poss . s i z e ( ) > 0) {f ina l BeanItemContainer<Str ing> ds = new BeanItemContainer<Str ing >(

80 poss ) ;

c . setContainerDataSource ( ds ) ;

i f ( datasource == null | | datasource . g e tS i lMinLeve lS t r ing ( ) == null )

c . setValue ( S i l L e v e l s .NEVER) ;

else

509

Page 528: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

c . setValue ( datasource . g e tS i lMinLeve lS t r ing ( ) ) ;

} else {c . setEnabled ( fa l se ) ;

}return c ;

90 } else i f ( ” f a t h e r A l t e r n a t i v e ” . equa l s ( propertyId ) ) {LinkedList<AlternativeAnswer> poss = new LinkedList<AlternativeAnswer >() ;

for ( Alternat iveAnswer a : a l t )

i f ( a . g e tFathe rA l t e rna t iv e ( ) == null )

poss . add ( a ) ;

Nat i v eSe l e c t c = new Nat iveSe l e c t ( ) ;

c . setWidth (COMMON FIELD WIDTH) ;

c . setCapt ion ( ” I s c h i l d o f f : ” ) ;

c . setNewItemsAllowed ( fa l se ) ;

c . s e tNu l l S e l e c t i onA l l owed ( true ) ;

100 i f ( poss . s i z e ( ) > 0) {f ina l BeanItemContainer<AlternativeAnswer> ds = new

BeanItemContainer<AlternativeAnswer >(

poss ) ;

c . setContainerDataSource ( ds ) ;

i f ( datasource != null )

c . setValue ( datasource . g e tFathe rA l t e rna t ive ( ) ) ;

} else {c . setEnabled ( fa l se ) ;

}return c ;

110 }return f ;

}

}

D.7.3 Classe AnswerHistoryFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . jpa . AnswsetHistory ;

import com . vaadin . data . Item ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

10 import com . vaadin . u i . RichTextArea ;

public class AnswerHistoryFie ldFactory extends Defau l tF i e ldFactory implements

FormFieldFactory {

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”24em” ;

private AnswsetHistory datasource ;

public AnswerHistoryFie ldFactory ( AnswsetHistory h i s t ) {20 datasource = h i s t ;

510

Page 529: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

@Override

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

i f ( ”comment” . equa l s ( propertyId ) ) {RichTextArea t f = new RichTextArea ( ) ;

t f . setCapt ion ( ”” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

30 t f . setValue ( datasource . getComment ( ) ) ;

return t f ;

}return f ;

}}

D.7.4 Classe AnswerSetFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . common . AnswerStatus ;

import i t . uniroma2 . norge . model . jpa . AnswerSet ;

import com . vaadin . data . Item ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

10 import com . vaadin . u i . FormFieldFactory ;

import com . vaadin . u i . Nat i v eSe l e c t ;

import com . vaadin . u i . TextFie ld ;

public class AnswerSetFie ldFactory extends Defau l tF i e ldFactory implements

FormFieldFactory {

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”30em” ;

private AnswerSet datasource ;

20private boolean f i l l i n g ;

public AnswerSetFie ldFactory ( AnswerSet ans , boolean b) {f i l l i n g = b ;

datasource = ans ;

}

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

30 i f ( ”openAnswer” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setRows (3 ) ;

t f . setCapt ion ( ”Open answer : ” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

i f ( datasource != null )

t f . setValue ( datasource . getOpenAnswer ( ) ) ;

511

Page 530: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

i f ( ! f i l l i n g )

t f . setEnabled ( fa l se ) ;

return t f ;

40 } else i f ( ”approvationComment” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ”Open answer comment : ” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

i f ( datasource != null )

t f . setValue ( datasource . getOpenAnswer ( ) ) ;

return t f ;

} else i f ( ” approvat ionStatus ” . equa l s ( propertyId ) ) {St r ing [ ] poss = new St r ing [ ] { AnswerStatus .PROPOSED, AnswerStatus .ACCEPTED,

AnswerStatus .REJECTED } ;

50 Nat iveSe l e c t c = new Nat iveSe l e c t ( ) ;

c . setWidth (COMMON FIELD WIDTH) ;

c . setCapt ion ( ”Open answer v a l i d a t i o n : ” ) ;

c . setNewItemsAllowed ( fa l se ) ;

for ( int i = 0 ; i < poss . l ength ; i++) {c . addItem ( poss [ i ] ) ;

}i f ( datasource . getApprovat ionStatus ( ) == null | |

datasource . getApprovat ionStatus ( ) . equa l s ( ”” ) )

c . setValue ( poss [ 0 ] ) ;

else

60 c . setValue ( datasource . getApprovat ionStatus ( ) . toLowerCase ( ) ) ;

return c ;

}return f ;

}

}

D.7.5 Classe AssignmentFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . jpa . Assignment ;

import i t . uniroma2 . norge . model . jpa . Role ;

import i t . uniroma2 . norge . model . jpa . User ;

import java . u t i l . L i s t ;

import com . vaadin . data . Item ;

10 import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

import com . vaadin . u i . Nat i v eSe l e c t ;

public class AssignmentFie ldFactory extends Defau l tF i e ldFactory implements

FormFieldFactory

{

512

Page 531: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

20 private Assignment datasource ;

private BeanItemContainer<Role> ro leDs ;

private BeanItemContainer<User> userDs ;

public AssignmentFie ldFactory ( )

{datasource = null ;

}30

public AssignmentFie ldFactory ( Assignment a )

{datasource = a ;

}

public void setRoleDs ( Lis t<Role> ds )

{ro leDs = new BeanItemContainer<Role>(ds ) ;

}40

public void setUserDs ( Lis t<User> ds )

{userDs = new BeanItemContainer<User>(ds ) ;

}

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext )

{Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

f ina l Nat iveSe l e c t r o l e = new Nat iveSe l e c t ( ”Role” ) ;

50 f ina l Nat iveSe l e c t user = new Nat iveSe l e c t ( ”User” ) ;

i f ( ” r o l e ” . equa l s ( propertyId ) ) {r o l e . setContainerDataSource ( ro leDs ) ;

r o l e . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

r o l e . se tRequi red ( true ) ;

i f ( datasource != null )

{r o l e . s e l e c t ( datasource . getRole ( ) ) ;

r o l e . setValue ( datasource . getRole ( ) ) ;

}60 return r o l e ;

} else i f ( ” user ” . equa l s ( propertyId ) ) {user . setContainerDataSource ( userDs ) ;

user . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

use r . se tRequi red ( true ) ;

i f ( datasource != null )

{user . s e l e c t ( datasource . getUser ( ) ) ;

user . setValue ( datasource . getUser ( ) ) ;

}70 return user ;

}return f ;

}

}

513

Page 532: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.7.6 Classe DefaultDeliverableFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . common . De l iverab leTypes ;

import i t . uniroma2 . norge . model . jpa . D e f a u l t D e l i v e r a b l e ;

import i t . uniroma2 . norge . model . jpa . Del ivCateg ;

import i t . uniroma2 . norge . model . jpa . Del ivSubcateg ;

import java . u t i l . L inkedLis t ;

import java . u t i l . L i s t ;

10import com . vaadin . data . Item ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

import com . vaadin . u i . Nat i v eSe l e c t ;

20 import com . vaadin . u i . TextFie ld ;

public class De fau l tDe l i v e r ab l eF i e l dFac to ry extends Defau l tF i e ldFactory

implements FormFieldFactory {

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”12em” ;

private D e f a u l t D e l i v e r a b l e datasource ;

private List<DelivCateg> model ;

30private Nat iveSe l e c t t yp eS e l e c t ;

private Nat iveSe l e c t typeSub1Se lect ;

private Nat iveSe l e c t typeSub2Se lect ;

private Nat iveSe l e c t ca t egSe l ;

private Nat iveSe l e c t subCategSel ;

40public De fau l tDe l i v e r ab l eF i e l dFac to ry ( Lis t<DelivCateg> dc ) {

datasource = null ;

model = dc ;

initComponents ( ) ;

}

public De fau l tDe l i v e r ab l eF i e l dFac to ry ( D e f a u l t D e l i v e r a b l e dh ,

L i s t<DelivCateg> dc ) {datasource = dh ;

50 model = dc ;

initComponents ( ) ;

}

private void initComponents ( ) {

514

Page 533: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

t yp eS e l e c t = new Nat iveSe l e c t ( ) ;

typeSub1Se lect = new Nat iveSe l e c t ( ) ;

typeSub2Se lect = new Nat iveSe l e c t ( ) ;

c a t egSe l = new Nat iveSe l e c t ( ) ;

subCategSel = new Nat iveSe l e c t ( ) ;

60 }

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

i f ( ”name” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ”Name” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r the name” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

70 i f ( datasource != null )

t f . setValue ( datasource . getName ( ) ) ;

return t f ;

} else i f ( ” d e s c r i p t i o n ” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ” Desc r ip t i on ” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r the d e s c r i p t i o n ” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

i f ( datasource != null )

80 t f . setValue ( datasource . g e tDe s c r i p t i on ( ) ) ;

return t f ;

} else i f ( ” type ” . equa l s ( propertyId ) ) {LinkedList<Str ing> poss = new LinkedList<Str ing >() ;

poss . add ( Del iverab leTypes .DOCUMENT) ;

poss . add ( Del iverab leTypes .ACTIVITY) ;

poss . add ( Del iverab leTypes .VARIOUS) ;

t yp eS e l e c t . setWidth (COMMON FIELD WIDTH) ;

t yp eS e l e c t . setCapt ion ( ”Type : ” ) ;

t yp eS e l e c t . setNewItemsAllowed ( fa l se ) ;

90 t yp eS e l e c t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

f ina l BeanItemContainer<Str ing> ds = new BeanItemContainer<Str ing >(

poss ) ;

t yp eS e l e c t . setContainerDataSource ( ds ) ;

i f ( datasource == null | | datasource . getType ( ) == null )

t yp eS e l e c t . setValue ( De l iverab leTypes .DOCUMENT) ;

else

t yp eS e l e c t . setValue ( datasource . getType ( ) ) ;

t yp eS e l e c t . setImmediate ( true ) ;

t yp eS e l e c t . addLis tener (new Property . ValueChangeListener ( ) {100 @Override

public void valueChange ( ValueChangeEvent event ) {i f ( event . getProperty ( ) == null

| | event . getProperty ( ) . t oS t r i ng ( ) == null )

return ;

i f ( ! t y pe Se l e c t . getValue ( )

. equa l s ( De l iverab leTypes .DOCUMENT) ) {typeSub1Se lect . setEnabled ( fa l se ) ;

typeSub2Se lect . setEnabled ( fa l se ) ;

} else {110 typeSub1Se lect . setEnabled ( true ) ;

515

Page 534: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

typeSub2Se lect . setEnabled ( true ) ;

}}

}) ;

return t yp eS e l e c t ;

} else i f ( ” subtype1 ” . equa l s ( propertyId ) ) {LinkedList<Str ing> poss = new LinkedList<Str ing >() ;

poss . add ( Del iverab leTypes . DocTypes1 .OFFSITE) ;

poss . add ( Del iverab leTypes . DocTypes1 .ONSITE) ;

120 typeSub1Se lect . setWidth (COMMON FIELD WIDTH) ;

typeSub1Se lect . setCapt ion ( ”On/ Off s i t e : ” ) ;

typeSub1Se lect . setNewItemsAllowed ( fa l se ) ;

typeSub1Se lect . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

f ina l BeanItemContainer<Str ing> ds = new BeanItemContainer<Str ing >(

poss ) ;

typeSub1Se lect . setContainerDataSource ( ds ) ;

i f ( datasource == null | | datasource . getSubtype1 ( ) == null )

typeSub1Se lect . setValue ( De l iverab leTypes . DocTypes1 .OFFSITE) ;

else

130 typeSub1Se lect . setValue ( datasource . getSubtype1 ( ) ) ;

return typeSub1Se lect ;

} else i f ( ” subtype2 ” . equa l s ( propertyId ) ) {LinkedList<Str ing> poss = new LinkedList<Str ing >() ;

poss . add ( Del iverab leTypes . DocTypes2 .NORMAL) ;

poss . add ( Del iverab leTypes . DocTypes2 . INFO) ;

typeSub2Se lect . setWidth (COMMON FIELD WIDTH) ;

typeSub2Se lect . setCapt ion ( ”For in fo rmat ion / v a l i d a t i o n : ” ) ;

typeSub2Se lect . setNewItemsAllowed ( fa l se ) ;

typeSub2Se lect . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

140 f ina l BeanItemContainer<Str ing> ds = new BeanItemContainer<Str ing >(

poss ) ;

typeSub2Se lect . setContainerDataSource ( ds ) ;

i f ( datasource == null | | datasource . getSubtype2 ( ) == null )

typeSub2Se lect . setValue ( De l iverab leTypes . DocTypes2 .NORMAL) ;

else

typeSub2Se lect . setValue ( datasource . getSubtype2 ( ) ) ;

return typeSub2Se lect ;

} else i f ( ” de l ivCateg ” . equa l s ( propertyId ) ) {ca t egSe l . setCapt ion ( ” Category ” ) ;

150 BeanItemContainer<DelivCateg> ds = new BeanItemContainer<DelivCateg >(

model ) ;

c a t egSe l . setContainerDataSource ( ds ) ;

c a t egSe l . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

c a t egSe l . se tRequi red ( true ) ;

i f ( datasource != null ) {ca t egSe l . s e l e c t ( datasource . getDel ivCateg ( ) ) ;

c a t egSe l . setValue ( datasource . getDel ivCateg ( ) ) ;

}ca t egSe l . addLis tener (new Property . ValueChangeListener ( ) {

160 @Override

public void valueChange ( ValueChangeEvent event ) {i f ( event . getProperty ( ) == null

| | event . getProperty ( ) . t oS t r i ng ( ) == null )

return ;

System . out . p r i n t l n ( event . getProperty ( ) . t oS t r i ng ( ) ) ;

L i s t<DelivSubcateg> tmp = ( ( Del ivCateg ) ca t egSe l . getValue ( ) )

516

Page 535: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

. ge tDe l ivSubcategs ( ) ;

i f (tmp != null & tmp . s i z e ( ) > 0) {BeanItemContainer<DelivSubcateg> ds = new

BeanItemContainer<DelivSubcateg >(

170 tmp) ;

subCategSel . setContainerDataSource ( ds ) ;

subCategSel . s e l e c t ( ds . getIdByIndex (0 ) ) ;

}subCategSel . requestRepa int ( ) ;

}}) ;

c a t egSe l . setImmediate ( true ) ;

return ca t egSe l ;

} else i f ( ” de l ivSubcateg ” . equa l s ( propertyId ) ) {180 subCategSel . setCapt ion ( ” Subcategory ” ) ;

subCategSel . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

subCategSel . se tRequi red ( true ) ;

i f ( datasource != null && datasource . getDe l ivSubcateg ( ) != null ) {List<DelivSubcateg> tmp = datasource . getDe l ivSubcateg ( )

. getDel ivCateg ( ) . ge tDe l ivSubcategs ( ) ;

i f (tmp != null && tmp . s i z e ( ) > 0) {BeanItemContainer<DelivSubcateg> ds = new

BeanItemContainer<DelivSubcateg >(

tmp) ;

subCategSel . setContainerDataSource ( ds ) ;

190 subCategSel . s e l e c t ( datasource . getDe l ivSubcateg ( ) ) ;

subCategSel . setValue ( datasource . getDe l ivSubcateg ( ) ) ;

}}subCategSel . setImmediate ( true ) ;

return subCategSel ;

}return f ;

}

200 }

D.7.7 Classe DelivContentHistoryFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . jpa . De l ive rab l eContentHi s to ry ;

import com . vaadin . data . Item ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

10 import com . vaadin . u i . RichTextArea ;

public class Del ivContentHis toryFie ldFactory extends Defau l tF i e ldFactory implements

FormFieldFactory {

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”24em” ;

517

Page 536: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private Del ive rab l eContentHi s to ry datasource ;

public Del ivContentHis toryFie ldFactory ( De l ive rab l eContentHi s to ry h i s t ) {20 datasource = h i s t ;

}

@Override

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

i f ( ”comment” . equa l s ( propertyId ) ) {RichTextArea t f = new RichTextArea ( ) ;

t f . setCapt ion ( ”” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

30 t f . setValue ( datasource . getComment ( ) ) ;

return t f ;

}return f ;

}}

D.7.8 Classe DeliverableFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . common . De l iverab leTypes ;

import i t . uniroma2 . norge . model . jpa . Del ivCateg ;

import i t . uniroma2 . norge . model . jpa . Del ivSubcateg ;

import i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e ;

import java . u t i l . L inkedLis t ;

import java . u t i l . L i s t ;

10import com . vaadin . data . Item ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . t e rmina l . S i z e a b l e ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

20 import com . vaadin . u i . Nat i v eSe l e c t ;

import com . vaadin . u i . TextFie ld ;

public class De l i v e rab l eF i e l dFac to ry extends Defau l tF i e ldFactory implements

FormFieldFactory {

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”12em” ;

private D e l i v e r a b l e datasource ;

30 private Nat iveSe l e c t t yp eS e l e c t ;

518

Page 537: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private Nat iveSe l e c t typeSub1Se lect ;

private Nat iveSe l e c t typeSub2Se lect ;

private Nat iveSe l e c t ca t egSe l ;

private Nat iveSe l e c t subCategSel ;

40 private List<DelivCateg> model ;

public De l i v e rab l eF i e l dFac to ry ( Lis t<DelivCateg> dc ) {datasource = null ;

model = dc ;

initComponents ( ) ;

}

public De l i v e rab l eF i e l dFac to ry ( D e l i v e r a b l e dh , L i s t<DelivCateg> dc ) {datasource = dh ;

50 model = dc ;

initComponents ( ) ;

}

private void initComponents ( ) {t yp eS e l e c t = new Nat iveSe l e c t ( ) ;

typeSub1Se lect = new Nat iveSe l e c t ( ) ;

typeSub2Se lect = new Nat iveSe l e c t ( ) ;

c a t egSe l = new Nat iveSe l e c t ( ) ;

subCategSel = new Nat iveSe l e c t ( ) ;

60 }

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

i f ( ”name” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ”Name” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r the name” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

70 i f ( datasource != null )

t f . setValue ( datasource . getName ( ) ) ;

return t f ;

} else i f ( ” d e s c r i p t i o n ” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ” Desc r ip t i on ” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r the d e s c r i p t i o n ” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

i f ( datasource != null )

80 t f . setValue ( datasource . g e tDe s c r i p t i on ( ) ) ;

return t f ;

} else i f ( ” type ” . equa l s ( propertyId ) ) {LinkedList<Str ing> poss = new LinkedList<Str ing >() ;

poss . add ( Del iverab leTypes .DOCUMENT) ;

poss . add ( Del iverab leTypes .ACTIVITY) ;

poss . add ( Del iverab leTypes .VARIOUS) ;

t yp eS e l e c t . setWidth (COMMON FIELD WIDTH) ;

519

Page 538: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

t yp eS e l e c t . setCapt ion ( ”Type : ” ) ;

t yp eS e l e c t . setNewItemsAllowed ( fa l se ) ;

90 t yp eS e l e c t . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

f ina l BeanItemContainer<Str ing> ds = new BeanItemContainer<Str ing >(

poss ) ;

t yp eS e l e c t . setContainerDataSource ( ds ) ;

i f ( datasource == null | | datasource . getType ( ) == null )

t yp eS e l e c t . setValue ( De l iverab leTypes .DOCUMENT) ;

else

t yp eS e l e c t . setValue ( datasource . getType ( ) ) ;

t yp eS e l e c t . setImmediate ( true ) ;

t yp eS e l e c t . addLis tener (new Property . ValueChangeListener ( ) {100 @Override

public void valueChange ( ValueChangeEvent event ) {i f ( event . getProperty ( ) == null

| | event . getProperty ( ) . t oS t r i ng ( ) == null )

return ;

i f ( ! t y pe Se l e c t . getValue ( )

. equa l s ( De l iverab leTypes .DOCUMENT) ) {typeSub1Se lect . setEnabled ( fa l se ) ;

typeSub2Se lect . setEnabled ( fa l se ) ;

} else {110 typeSub1Se lect . setEnabled ( true ) ;

typeSub2Se lect . setEnabled ( true ) ;

}}

}) ;

return t yp eS e l e c t ;

} else i f ( ” subtype1 ” . equa l s ( propertyId ) ) {LinkedList<Str ing> poss = new LinkedList<Str ing >() ;

poss . add ( Del iverab leTypes . DocTypes1 .OFFSITE) ;

poss . add ( Del iverab leTypes . DocTypes1 .ONSITE) ;

120 typeSub1Se lect . setWidth (COMMON FIELD WIDTH) ;

typeSub1Se lect . setCapt ion ( ”On/ Off s i t e : ” ) ;

typeSub1Se lect . setNewItemsAllowed ( fa l se ) ;

typeSub1Se lect . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

f ina l BeanItemContainer<Str ing> ds = new BeanItemContainer<Str ing >(

poss ) ;

typeSub1Se lect . setContainerDataSource ( ds ) ;

i f ( datasource == null | | datasource . getSubtype1 ( ) == null )

typeSub1Se lect . setValue ( De l iverab leTypes . DocTypes1 .OFFSITE) ;

else

130 typeSub1Se lect . setValue ( datasource . getSubtype1 ( ) ) ;

return typeSub1Se lect ;

} else i f ( ” subtype2 ” . equa l s ( propertyId ) ) {LinkedList<Str ing> poss = new LinkedList<Str ing >() ;

poss . add ( Del iverab leTypes . DocTypes2 .NORMAL) ;

poss . add ( Del iverab leTypes . DocTypes2 . INFO) ;

typeSub2Se lect . setWidth (COMMON FIELD WIDTH) ;

typeSub2Se lect . setCapt ion ( ”Normal/ Information−only : ” ) ;

typeSub2Se lect . setNewItemsAllowed ( fa l se ) ;

typeSub2Se lect . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

140 f ina l BeanItemContainer<Str ing> ds = new BeanItemContainer<Str ing >(

poss ) ;

typeSub2Se lect . setContainerDataSource ( ds ) ;

i f ( datasource == null | | datasource . getSubtype2 ( ) == null )

520

Page 539: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

typeSub2Se lect . setValue ( De l iverab leTypes . DocTypes2 .NORMAL) ;

else

typeSub2Se lect . setValue ( datasource . getSubtype2 ( ) ) ;

return typeSub2Se lect ;

} else i f ( ” de l ivCateg ” . equa l s ( propertyId ) ) {ca t egSe l . setCapt ion ( ” Category ” ) ;

150 ca t egSe l . setWidth (24 , S i z e a b l e .UNITS EM) ;

BeanItemContainer<DelivCateg> ds = new BeanItemContainer<DelivCateg >(

model ) ;

c a t egSe l . setContainerDataSource ( ds ) ;

c a t egSe l . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

c a t egSe l . se tRequi red ( true ) ;

i f ( datasource != null ) {ca t egSe l . s e l e c t ( datasource . getDel ivCateg ( ) ) ;

c a t egSe l . setValue ( datasource . getDel ivCateg ( ) ) ;

}160 ca t egSe l . addLis tener (new Property . ValueChangeListener ( ) {

@Override

public void valueChange ( ValueChangeEvent event ) {i f ( event . getProperty ( ) == null

| | event . getProperty ( ) . t oS t r i ng ( ) == null )

return ;

System . out . p r i n t l n ( event . getProperty ( ) . t oS t r i ng ( ) ) ;

L i s t<DelivSubcateg> tmp = ( ( Del ivCateg ) ca t egSe l . getValue ( ) )

. ge tDe l ivSubcategs ( ) ;

i f (tmp != null & tmp . s i z e ( ) > 0) {170 BeanItemContainer<DelivSubcateg> ds = new

BeanItemContainer<DelivSubcateg >(

tmp) ;

subCategSel . setContainerDataSource ( ds ) ;

subCategSel . s e l e c t ( ds . getIdByIndex (0 ) ) ;

}subCategSel . requestRepa int ( ) ;

}}) ;

c a t egSe l . setImmediate ( true ) ;

return ca t egSe l ;

180 } else i f ( ” de l ivSubcateg ” . equa l s ( propertyId ) ) {subCategSel . setCapt ion ( ” Subcategory ” ) ;

subCategSel . setWidth (24 , S i z e a b l e .UNITS EM) ;

subCategSel . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

subCategSel . se tRequi red ( true ) ;

i f ( datasource != null && datasource . getDe l ivSubcateg ( ) != null ) {List<DelivSubcateg> tmp = datasource . getDe l ivSubcateg ( )

. getDel ivCateg ( ) . ge tDe l ivSubcategs ( ) ;

i f (tmp != null && tmp . s i z e ( ) > 0) {BeanItemContainer<DelivSubcateg> ds = new

BeanItemContainer<DelivSubcateg >(

190 tmp) ;

subCategSel . setContainerDataSource ( ds ) ;

subCategSel . s e l e c t ( datasource . getDe l ivSubcateg ( ) ) ;

subCategSel . setValue ( datasource . getDe l ivSubcateg ( ) ) ;

}}subCategSel . setImmediate ( true ) ;

return subCategSel ;

521

Page 540: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}return f ;

200 }

}

D.7.9 Classe DeliverableHistoryFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e H i s t o r y ;

import com . vaadin . data . Item ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

10 import com . vaadin . u i . RichTextArea ;

public class De l i v e rab l eH i s t o ryF i e l dFac to ry extends Defau l tF i e ldFactory implements

FormFieldFactory {

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”24em” ;

private D e l i v e r a b l e H i s t o r y datasource ;

public De l i v e rab l eH i s t o ryF i e l dFac to ry ( D e l i v e r a b l e H i s t o r y h i s t ) {20 datasource = h i s t ;

}

@Override

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

i f ( ”comment” . equa l s ( propertyId ) ) {RichTextArea t f = new RichTextArea ( ) ;

t f . setCapt ion ( ”” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

30 t f . setValue ( datasource . getComment ( ) ) ;

return t f ;

}return f ;

}}

D.7.10 Classe DocumentHistoryFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . jpa . DocumentHistory ;

import com . vaadin . data . Item ;

522

Page 541: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

10 import com . vaadin . u i . RichTextArea ;

public class DocumentHistoryFieldFactory extends Defau l tF i e ldFactory implements

FormFieldFactory {

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”24em” ;

private DocumentHistory datasource ;

public DocumentHistoryFieldFactory ( DocumentHistory h i s t ) {20 datasource = h i s t ;

}

@Override

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

i f ( ”comment” . equa l s ( propertyId ) ) {RichTextArea t f = new RichTextArea ( ) ;

t f . setCapt ion ( ”” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

30 t f . setValue ( datasource . getComment ( ) ) ;

return t f ;

}return f ;

}}

D.7.11 Classe FillingoutFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import com . vaadin . data . Container ;

import com . vaadin . u i . CheckBox ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . TableFie ldFactory ;

public class F i l l i n g o u t F i e l d F a c t o r y implements TableFie ldFactory {10

private stat ic f ina l long se r ia lVer s ionUID = 412645525750774576L ;

@Override

public Fie ld c r e a t e F i e l d ( Container conta iner , Object itemId ,

Object propertyId , Component uiContext ) {CheckBox response = new CheckBox ( ) ;

i f ( ” re sponse ” . equa l s ( propertyId ) ) {return re sponse ;

}20 return null ;

}

523

Page 542: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

D.7.12 Classe ModelFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . jpa . Model ;

import com . vaadin . data . Item ;

import com . vaadin . data . v a l i d a t o r . St r ingLengthVal idator ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

10 import com . vaadin . u i . FormFieldFactory ;

import com . vaadin . u i . TextFie ld ;

public class ModelFie ldFactory extends Defau l tF i e ldFactory implements

FormFieldFactory

{

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”12em” ;

private Model datasource ;

20 public ModelFie ldFactory ( )

{datasource = null ;

}

public ModelFie ldFactory ( Model ans )

{datasource = ans ;

}

30 public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext )

{Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

i f ( ” d e s c r i p t i o n ” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ” Desc r ip t i on ” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r the d e s c r i p t i o n ” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

t f . addVal idator (new Str ingLengthVal idator (

40 ” Desc r ip t i on must be 1−255 c h a r a c t e r s ” , 1 , 255 , fa l se ) ) ;

i f ( datasource != null )

t f . setValue ( datasource . g e tDe s c r i p t i on ( ) ) ;

return t f ;

}return f ;

}

}

524

Page 543: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.7.13 Classe OrganizationFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . jpa . Organizat ion ;

import com . vaadin . data . Item ;

import com . vaadin . data . v a l i d a t o r . St r ingLengthVal idator ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

10 import com . vaadin . u i . FormFieldFactory ;

import com . vaadin . u i . Nat i v eSe l e c t ;

import com . vaadin . u i . TextFie ld ;

public class Organ izat ionFie ldFactory extends Defau l tF i e ldFactory implements

FormFieldFactory {

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”12em” ;

private Organizat ion datasource ;

20public Organ izat ionFie ldFactory ( ) {

datasource = null ;

}

public Organ izat ionFie ldFactory ( Organizat ion user ) {datasource = user ;

}

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {30 Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

i f ( ” country ” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ”Country” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r the country ” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

t f . addVal idator (new Str ingLengthVal idator (

”Country must be 3 c h a r a c t e r s ( ISO 3166−1 alpha−3)” , 3 , 3 , fa l se ) ) ;

i f ( datasource != null )

40 t f . setValue ( datasource . getName ( ) ) ;

return t f ;

} else i f ( ”name” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ”Name” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r name and surname” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

t f . addVal idator (new Str ingLengthVal idator (

”Name must be 1−255 c h a r a c t e r s ” , 1 , 255 , fa l se ) ) ;

50 i f ( datasource != null )

t f . setValue ( datasource . getName ( ) ) ;

return t f ;

} else i f ( ” type ” . equa l s ( propertyId ) ) {Nat iveSe l e c t n s e l = new Nat iveSe l e c t ( ) ;

525

Page 544: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

n s e l . setCapt ion ( ”Type” ) ;

n s e l . addItem ( ” Software house ” ) ;

n s e l . addItem ( ” P r o f e s s i o n a l c e r t i f i c a t i o n ” ) ;

n s e l . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

n s e l . se tRequi red ( true ) ;

60 i f ( datasource != null ) {n s e l . s e l e c t ( datasource . getType ( ) ) ;

n s e l . setValue ( datasource . getType ( ) ) ;

}return n s e l ;

}return f ;

}

}

D.7.14 Classe QuestionFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . ClassManager ;

import i t . uniroma2 . norge . model . jpa . Mclass ;

import i t . uniroma2 . norge . model . jpa . Model ;

import i t . uniroma2 . norge . model . jpa . Mpackage ;

import i t . uniroma2 . norge . model . jpa . Question ;

import java . u t i l . ArrayList ;

10 import java . u t i l . L i s t ;

import com . vaadin . data . Item ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . data . v a l i d a t o r . St r ingLengthVal idator ;

import com . vaadin . u i . CheckBox ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

20 import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

import com . vaadin . u i . Nat i v eSe l e c t ;

import com . vaadin . u i . TextFie ld ;

public class Quest ionFie ldFactory extends Defau l tF i e ldFactory implements

FormFieldFactory {

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”12em” ;

30 private Question datasource ;

private Nat iveSe l e c t open ;

private Nat iveSe l e c t type ;

private TextFie ld tfLB ;

526

Page 545: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private TextFie ld tfUB ;

40 private Nat iveSe l e c t mpackage ;

private Nat iveSe l e c t mclass ;

private ClassManager c t r l C l a s s ;

private Model model ;

public Quest ionFie ldFactory ( Model model ) {this . model = model ;

50 datasource = null ;

initComponents ( ) ;

}

public Quest ionFie ldFactory ( Question qst ) {this . model = qst . ge tQues t i onna i r e ( ) . getModel ( ) ;

datasource = qst ;

initComponents ( ) ;

}

60 public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

i f ( ” ques t i on ” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ” Question ” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r the ques t i on ” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

t f . addVal idator (new Str ingLengthVal idator (

” Question must be 1−255 c h a r a c t e r s ” , 1 , 255 , fa l se ) ) ;

70 i f ( datasource != null )

t f . setValue ( datasource . getQuest ion ( ) ) ;

return t f ;

} else i f ( ” questionCode ” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ” Question code ” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r the ques t i on code ” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

t f . addVal idator (new Str ingLengthVal idator (

80 ” Question must be 1−255 c h a r a c t e r s ” , 1 , 255 , fa l se ) ) ;

i f ( datasource != null )

t f . setValue ( datasource . getQuest ion ( ) ) ;

return t f ;

} else i f ( ” s i n g l e M u l t i p l e o l d ” . equa l s ( propertyId ) ) {type . addItem ( ” s i n g l e cho i c e ” ) ;

type . addItem ( ” mul t ip l e cho i c e ” ) ;

type . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

i f ( datasource != null ) {type . s e l e c t ( datasource . g e t S i n g l e M u l t i p l e ( ) ) ;

90 type . setValue ( datasource . g e t S i n g l e M u l t i p l e ( ) ) ;

}return type ;

527

Page 546: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

} else i f ( ”mpackage” . equa l s ( propertyId ) ) {BeanItemContainer<Mpackage> ds = new BeanItemContainer<Mpackage>(

model . getMpackages ( ) ) ;

mpackage . setContainerDataSource ( ds ) ;

i f ( datasource != null ) {mpackage . s e l e c t ( datasource . getMpackage ( ) ) ;

mpackage . setValue ( datasource . getMpackage ( ) ) ;

100 mpackage . setEnabled ( ! datasource . g e tContex tDe f in i t i on ( ) ) ;

}mpackage . addLis tener (new Property . ValueChangeListener ( ) {

@Override

public void valueChange ( ValueChangeEvent event ) {i f ( event . getProperty ( ) == null

| | event . getProperty ( ) . t oS t r i ng ( ) == null )

return ;

System . out . p r i n t l n ( event . getProperty ( ) . t oS t r i ng ( ) ) ;

L i s t<Mclass> tmp = c t r l C l a s s . v iewAl l ( ( Mpackage ) mpackage

110 . getValue ( ) ) ;

i f (tmp != null & tmp . s i z e ( ) > 0) {BeanItemContainer<Mclass> ds = new BeanItemContainer<Mclass>(

tmp) ;

mclass . setContainerDataSource ( ds ) ;

mclass . s e l e c t ( ds . getIdByIndex (0 ) ) ;

}mclass . requestRepa int ( ) ;

}}) ;

120 mpackage . setImmediate ( true ) ;

return mpackage ;

} else i f ( ” mclass ” . equa l s ( propertyId ) ) {i f ( datasource != null && datasource . getMpackage ( ) != null ) {

List<Mclass> tmp = c t r l C l a s s . v iewAl l ( datasource . getMpackage ( ) ) ;

i f (tmp != null && tmp . s i z e ( ) > 0) {BeanItemContainer<Mclass> ds = new BeanItemContainer<Mclass>(

tmp) ;

mclass . setContainerDataSource ( ds ) ;

mclass . s e l e c t ( datasource . getMclass ( ) ) ;

130 mclass . setValue ( datasource . getMclass ( ) ) ;

}mclass . setEnabled ( ! datasource . g e tContex tDe f in i t i on ( ) ) ;

}mclass . setImmediate ( true ) ;

return mclass ;

} else i f ( ” lowerbound” . equa l s ( propertyId ) ) {TextFie ld t f = tfLB ;

t f . setCapt ion ( ”Lower bound” ) ;

t f . s e tRequi red ( fa l se ) ;

140 t f . setWidth (COMMON FIELD WIDTH) ;

i f ( datasource != null )

t f . setValue ( datasource . getLowerbound ( ) ) ;

t f . setEnabled ( fa l se ) ;

t f . setImmediate ( true ) ;

return t f ;

} else i f ( ”upperbound” . equa l s ( propertyId ) ) {TextFie ld t f = tfUB ;

t f . setCapt ion ( ”Upper bound” ) ;

528

Page 547: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

t f . s e tRequi red ( fa l se ) ;

150 t f . setWidth (COMMON FIELD WIDTH) ;

i f ( datasource != null )

t f . setValue ( datasource . getUpperbound ( ) ) ;

t f . setEnabled ( fa l se ) ;

t f . setImmediate ( true ) ;

return t f ;

} else i f ( ” s i n g l e M u l t i p l e ” . equa l s ( propertyId ) ) {ArrayList<Str ing> elem = new ArrayList<Str ing >() ;

elem . add ( ” 0 . . 1 ” ) ;

elem . add ( ”1” ) ;

160 elem . add ( ” 0 . . n” ) ;

elem . add ( ”n . .m” ) ;

f ina l BeanItemContainer<Str ing> ds = new BeanItemContainer<Str ing >(

elem ) ;

type . setContainerDataSource ( ds ) ;

type . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

type . setRequi red ( true ) ;

i f ( datasource != null ) {tfUB . setEnabled ( fa l se ) ;

tfLB . setEnabled ( fa l se ) ;

170 i f ( datasource . g e t S i n g l e M u l t i p l e ( ) != null ) {type . s e l e c t ( datasource . g e t S i n g l e M u l t i p l e ( ) ) ;

type . setValue ( datasource . g e t S i n g l e M u l t i p l e ( ) ) ;

i f ( datasource . g e t S i n g l e M u l t i p l e ( ) . equa l s ( ” 0 . . n” ) ) {tfUB . setEnabled ( true ) ;

} else i f ( datasource . g e t S i n g l e M u l t i p l e ( ) . equa l s ( ”n . .m” ) ) {tfUB . setEnabled ( true ) ;

tfLB . setEnabled ( true ) ;

}}

180 }type . setImmediate ( true ) ;

type . addLis tener (new Property . ValueChangeListener ( ) {@Override

public void valueChange ( ValueChangeEvent event ) {i f ( event . getProperty ( ) == null

| | event . getProperty ( ) . t oS t r i ng ( ) == null )

return ;

System . out . p r i n t l n ( ”E ’ s t a t o s e l e z i o n a t o i l va l o r e ”

+ event . getProperty ( ) . t oS t r i ng ( ) ) ;

190 tfUB . setEnabled ( fa l se ) ;

tfLB . setEnabled ( fa l se ) ;

i f ( event . getProperty ( ) . t oS t r i ng ( ) . equa l s ( ” 0 . . n” ) ) {tfUB . setEnabled ( true ) ;

tfLB . setEnabled ( fa l se ) ;

} else i f ( event . getProperty ( ) . t oS t r i ng ( ) . equa l s ( ”n . .m” ) ) {tfUB . setEnabled ( true ) ;

tfLB . setEnabled ( true ) ;

} else i f ( event . getProperty ( ) . t oS t r i ng ( ) . equa l s ( ” 0 . . 1 ” ) ) {tfUB . setValue ( ”1” ) ;

200 tfLB . setValue ( ”0” ) ;

} else i f ( event . getProperty ( ) . t oS t r i ng ( ) . equa l s ( ”1” ) ) {tfUB . setValue ( ”1” ) ;

tfLB . setValue ( ”1” ) ;

} else {

529

Page 548: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

tfUB . setEnabled ( fa l se ) ;

tfLB . setEnabled ( fa l se ) ;

}}

}) ;

210 return type ;

} else i f ( ” openQuestion ” . equa l s ( propertyId ) ) {St r ing defaultNo = ”no” ;

open . removeAllItems ( ) ;

open . addItem ( defaultNo ) ;

open . addItem ( ” yes ” ) ;

open . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

i f ( datasource != null && datasource . g e t S i n g l e M u l t i p l e ( ) != null ) {open . s e l e c t ( datasource . g e t S i n g l e M u l t i p l e ( ) ) ;

open . setValue ( datasource . g e t S i n g l e M u l t i p l e ( ) ) ;

220 open . setEnabled ( ! datasource . g e tContex tDe f in i t i on ( ) ) ;

} else {open . s e l e c t ( defaultNo ) ;

open . setValue ( defaultNo ) ;

}return open ;

} else i f ( ” c o n t e x t D e f i n i t i o n ” . equa l s ( propertyId ) ) {f ina l CheckBox cb = new CheckBox ( ) ;

cb . setCapt ion ( ”Context d e f i n i t i o n ” ) ;

cb . setImmediate ( true ) ;

230 i f ( datasource != null && datasource . g e t S i n g l e M u l t i p l e ( ) != null ) {cb . setValue ( datasource . g e tContex tDe f in i t i on ( ) ) ;

} else {cb . setValue ( fa l se ) ;

}cb . addLis tener (new Property . ValueChangeListener ( ) {

@Override

public void valueChange ( ValueChangeEvent event ) {Boolean v = ( Boolean ) cb . getValue ( ) ;

i f ( v != null ) {240 mclass . setEnabled ( ! v ) ;

mpackage . setEnabled ( ! v ) ;

open . setEnabled ( ! v ) ;

}}

}) ;

return cb ;

}return f ;

}250

private void initComponents ( ) {c t r l C l a s s = new ClassManager ( ) ;

type = new Nat iveSe l e c t ( ”Type” ) ;

open = new Nat iveSe l e c t ( ”Open answer” ) ;

mpackage = new Nat iveSe l e c t ( ”Package” ) ;

mclass = new Nat iveSe l e c t ( ” Class ” ) ;

tfLB = new TextFie ld ( ) ;

tfUB = new TextFie ld ( ) ;

}260

530

Page 549: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

D.7.15 Classe QuestionnaireFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . ModelManager ;

import i t . uniroma2 . norge . model . jpa . Model ;

import i t . uniroma2 . norge . model . jpa . Quest ionna i re ;

import com . vaadin . data . Item ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . data . v a l i d a t o r . St r ingLengthVal idator ;

10 import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

import com . vaadin . u i . Nat i v eSe l e c t ;

import com . vaadin . u i . TextFie ld ;

public class Quest ionna i r eF i e ldFactory extends Defau l tF i e ldFactory implements

FormFieldFactory {

20 private stat ic f ina l St r ing COMMON FIELD WIDTH = ”12em” ;

private Quest ionna i re datasource ;

public Quest ionna i r eF i e ldFactory ( ) {datasource = null ;

}

public Quest ionna i r eF i e ldFactory ( Quest ionna i re qst ) {datasource = qst ;

30 }

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

f ina l Nat iveSe l e c t model = new Nat iveSe l e c t ( ”UML r e v i s i o n ” ) ;

i f ( ”name” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ” Quest ionna i re name” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r the new p r o j e c t ’ s name” ) ;

40 t f . setWidth (COMMON FIELD WIDTH) ;

t f . addVal idator (new Str ingLengthVal idator (

”Name must be 1−255 c h a r a c t e r s ” , 1 , 255 , fa l se ) ) ;

return t f ;

} else i f ( ”model” . equa l s ( propertyId ) ) {ModelManager ctrModel = new ModelManager ( ) ;

BeanItemContainer<Model> ds = new BeanItemContainer<Model>(ctrModel

. v iewAl l ( ) ) ;

model . setContainerDataSource ( ds ) ;

model . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

50 model . se tRequi red ( true ) ;

531

Page 550: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

model

. s e tRequ i redError ( ” I t ’ s nece s sa ry to s p e c i f y the UML Model a s s o c i a t e d to

t h i s q u e s t i o n n a i r e ” ) ;

i f ( datasource != null ) {model . s e l e c t ( datasource . getModel ( ) ) ;

model . setValue ( datasource . getModel ( ) ) ;

}return model ;

}return f ;

60 }

}

D.7.16 Classe ResponseFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . jpa . Alternat iveAnswer ;

import i t . uniroma2 . norge . model . jpa . AnswerSet ;

import i t . uniroma2 . norge . model . jpa . Question ;

import java . u t i l . ArrayList ;

import com . vaadin . data . Item ;

10 import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

import com . vaadin . u i . OptionGroup ;

public class ResponseFie ldFactory extends Defau l tF i e ldFactory implements

FormFieldFactory {private AnswerSet datasource ;

20private Question ques t i on ;

public ResponseFie ldFactory ( Question qst , AnswerSet a ) {ques t i on = qst ;

datasource = a ;

}

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

30 OptionGroup optgr = new OptionGroup ( ”” ) ;

i f ( propertyId . t oS t r i ng ( ) . conta in s ( ”answsetAnsws” ) ) {ArrayList<AlternativeAnswer> l = new ArrayList<AlternativeAnswer >() ;

l . addAll ( ques t i on . getAlternat iveAnswers ( ) ) ;

BeanItemContainer<AlternativeAnswer> ds = new

BeanItemContainer<AlternativeAnswer >(

l ) ;

optgr . setContainerDataSource ( ds ) ;

optgr . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

532

Page 551: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

optgr . se tRequi red ( true ) ;

i f ( datasource != null ) {40 }

i f ( ques t i on != null && ques t i on . g e t S i n g l e M u l t i p l e ( ) != null

&& ! ques t i on . g e t S i n g l e M u l t i p l e ( ) . conta in s ( ” s i n g l e ” ) )

optgr . s e t M u l t i S e l e c t ( true ) ;

return optgr ;

}return f ;

}

}

D.7.17 Classe RuleExcFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . jpa . Alternat iveAnswer ;

import i t . uniroma2 . norge . model . jpa . Question ;

import i t . uniroma2 . norge . model . jpa . Quest ionna i re ;

import i t . uniroma2 . norge . model . jpa . RuleExclus ion ;

import java . u t i l . L i s t ;

10 import com . vaadin . data . Item ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

import com . vaadin . u i . Nat i v eSe l e c t ;

import com . vaadin . u i . TextFie ld ;

20public class RuleExcFieldFactory extends Defau l tF i e ldFactory implements

FormFieldFactory {

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”12em” ;

private RuleExclus ion datasource ;

private Nat iveSe l e c t ques t i on ;

30 private Nat iveSe l e c t answer ;

private Quest ionna i re questn ;

public RuleExcFieldFactory ( Quest ionna i re q ) {datasource = null ;

questn = q ;

initComponents ( ) ;

}

533

Page 552: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

40 public RuleExcFieldFactory ( RuleExclus ion r , Quest ionna i re q ) {datasource = r ;

questn = q ;

initComponents ( ) ;

}

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

i f ( ” qua lcosa ” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

50 t f . setCapt ion ( ” Qualcosa ” ) ;

t f . s e tRequi red ( fa l se ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

i f ( datasource != null )

t f . setValue ( datasource . getAlternat iveAnswerTarget ( ) ) ;

return t f ;

} else i f ( ” ques t i on ” . equa l s ( propertyId ) ) {BeanItemContainer<Question> ds = new BeanItemContainer<Question >(

questn . getQuest ions ( ) ) ;

ques t i on . setContainerDataSource ( ds ) ;

60 ques t i on . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

ques t i on . setRequi red ( true ) ;

i f ( datasource != null ) {ques t i on . s e l e c t ( datasource . getQuest ion ( ) ) ;

ques t i on . setValue ( datasource . getQuest ion ( ) ) ;

}ques t i on . addLis tener (new Property . ValueChangeListener ( ) {

@Override

public void valueChange ( ValueChangeEvent event ) {System . out . p r i n t l n ( ”E ’ s t a t o s e l e z i o n a t o i l va l o r e ”

70 + event . getProperty ( ) . t oS t r i ng ( ) ) ;

i f ( true ) {List<AlternativeAnswer> tmp = ( ( Question ) ques t i on

. getValue ( ) ) . getAlternat iveAnswers ( ) ;

i f ( datasource != null

&& datasource . getAlternat iveAnswerSource ( ) != null

&& tmp . conta in s ( datasource

. getAlternat iveAnswerSource ( ) ) )

tmp . remove ( datasource . getAlternat iveAnswerSource ( ) ) ;

BeanItemContainer<AlternativeAnswer> answerDS = new

BeanItemContainer<AlternativeAnswer >(

80 tmp) ;

answer . setContainerDataSource ( answerDS ) ;

}answer . requestRepa int ( ) ;

}}) ;

ques t i on . setImmediate ( true ) ;

return ques t i on ;

} else i f ( ” a l te rnat iveAnswerTarget ” . equa l s ( propertyId ) ) {answer . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

90 answer . se tRequi red ( true ) ;

i f ( datasource != null ) {List<AlternativeAnswer> tmp = datasource . getQuest ion ( )

. getAlternat iveAnswers ( ) ;

i f (tmp . conta in s ( datasource . getAlternat iveAnswerSource ( ) ) )

534

Page 553: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

tmp . remove ( datasource . getAlternat iveAnswerSource ( ) ) ;

BeanItemContainer<AlternativeAnswer> answerDS = new

BeanItemContainer<AlternativeAnswer >(

tmp) ;

answer . setContainerDataSource ( answerDS ) ;

answer . s e l e c t ( datasource . getAlternat iveAnswerTarget ( ) ) ;

100 answer . setValue ( datasource . getAlternat iveAnswerTarget ( ) ) ;

}answer . setImmediate ( true ) ;

return answer ;

}return f ;

}

private void initComponents ( ) {ques t i on = new Nat iveSe l e c t ( ” Question ” ) ;

110 answer = new Nat iveSe l e c t ( ”Answer” ) ;

}

}

D.7.18 Classe RuleMulFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . jpa . Question ;

import i t . uniroma2 . norge . model . jpa . Quest ionna i re ;

import i t . uniroma2 . norge . model . jpa . Ru l eMul t ep l i c i ty ;

import java . u t i l . ArrayList ;

import com . vaadin . data . Item ;

10 import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . data . u t i l . BeanItemContainer ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

import com . vaadin . u i . Nat i v eSe l e c t ;

import com . vaadin . u i . TextFie ld ;

20 public class RuleMulFieldFactory extends Defau l tF i e ldFactory implements

FormFieldFactory {

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”12em” ;

private RuleMul t ep l i c i ty datasource ;

private Nat iveSe l e c t ques t i on ;

private Nat iveSe l e c t type ;

30private TextFie ld tfLB ;

535

Page 554: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

private TextFie ld tfUB ;

private Quest ionna i re questn ;

public RuleMulFieldFactory ( Quest ionna i re q ) {datasource = null ;

questn = q ;

40 i n i t F i e l d s ( ) ;

}

public RuleMulFieldFactory ( Ru l eMul t ep l i c i ty r , Quest ionna i re q ) {datasource = r ;

questn = q ;

i n i t F i e l d s ( ) ;

}

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {50 i f ( ” lowebound” . equa l s ( propertyId ) ) {

TextFie ld t f = tfLB ;

t f . setCapt ion ( ”Lower bound” ) ;

t f . s e tRequi red ( fa l se ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

i f ( datasource != null )

t f . setValue ( datasource . getLowebound ( ) ) ;

t f . setEnabled ( fa l se ) ;

t f . setImmediate ( true ) ;

return t f ;

60 } else i f ( ”upperbound” . equa l s ( propertyId ) ) {TextFie ld t f = tfUB ;

t f . setCapt ion ( ”Upper bound” ) ;

t f . s e tRequi red ( fa l se ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

i f ( datasource != null )

t f . setValue ( datasource . getUpperbound ( ) ) ;

t f . setEnabled ( fa l se ) ;

t f . setImmediate ( true ) ;

return t f ;

70 } else i f ( ” ques t i on ” . equa l s ( propertyId ) ) {BeanItemContainer<Question> ds = new BeanItemContainer<Question >(

questn . getQuest ions ( ) ) ;

ques t i on . setContainerDataSource ( ds ) ;

ques t i on . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

ques t i on . setRequi red ( true ) ;

i f ( datasource != null ) {type . s e l e c t ( datasource . getQuest ion ( ) ) ;

type . setValue ( datasource . getQuest ion ( ) ) ;

}80 ques t i on . setImmediate ( true ) ;

return ques t i on ;

} else i f ( ” type ” . equa l s ( propertyId ) ) {ArrayList<Str ing> elem = new ArrayList<Str ing >() ;

elem . add ( ” 0 . . 1 ” ) ;

elem . add ( ”1” ) ;

elem . add ( ” 0 . . n” ) ;

elem . add ( ”n . .m” ) ;

536

Page 555: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

f ina l BeanItemContainer<Str ing> ds = new BeanItemContainer<Str ing >(

elem ) ;

90 type . setContainerDataSource ( ds ) ;

type . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

type . setRequi red ( true ) ;

i f ( datasource != null ) {type . s e l e c t ( datasource . getType ( ) ) ;

type . setValue ( datasource . getType ( ) ) ;

tfUB . setEnabled ( fa l se ) ;

tfLB . setEnabled ( fa l se ) ;

i f ( datasource . getType ( ) . equa l s ( ” 0 . . n” ) ) {tfUB . setEnabled ( true ) ;

100 } else i f ( datasource . getType ( ) . equa l s ( ”n . .m” ) ) {tfUB . setEnabled ( true ) ;

tfLB . setEnabled ( true ) ;

}}type . setImmediate ( true ) ;

type . addLis tener (new Property . ValueChangeListener ( ) {@Override

public void valueChange ( ValueChangeEvent event ) {System . out . p r i n t l n ( ”E ’ s t a t o s e l e z i o n a t o i l va l o r e ”

110 + event . getProperty ( ) . t oS t r i ng ( ) ) ;

i f ( event . getProperty ( ) . t oS t r i ng ( ) . equa l s ( ” 0 . . n” ) ) {tfUB . setEnabled ( true ) ;

tfLB . setEnabled ( fa l se ) ;

} else i f ( event . getProperty ( ) . t oS t r i ng ( ) . equa l s ( ”n . .m” ) ) {tfUB . setEnabled ( true ) ;

tfLB . setEnabled ( true ) ;

} else {tfUB . setEnabled ( fa l se ) ;

tfLB . setEnabled ( fa l se ) ;

120 }}

}) ;

return type ;

}return new TextFie ld ( ) ;

}

private void i n i t F i e l d s ( ) {tfLB = new TextFie ld ( ) ;

130 tfUB = new TextFie ld ( ) ;

ques t i on = new Nat iveSe l e c t ( ” Question ” ) ;

type = new Nat iveSe l e c t ( ”Type” ) ;

}

}

D.7.19 Classe UserFieldFactory.java

package i t . uniroma2 . norge . web . f i e l d f a c t o r y ;

import i t . uniroma2 . norge . model . jpa . Organizat ion ;

537

Page 556: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import i t . uniroma2 . norge . model . jpa . User ;

import java . u t i l . L i s t ;

import com . vaadin . data . Item ;

import com . vaadin . data . u t i l . BeanItemContainer ;

10 import com . vaadin . data . v a l i d a t o r . St r ingLengthVal idator ;

import com . vaadin . u i . Component ;

import com . vaadin . u i . De fau l tF i e ldFactory ;

import com . vaadin . u i . F i e ld ;

import com . vaadin . u i . FormFieldFactory ;

import com . vaadin . u i . Nat i v eSe l e c t ;

import com . vaadin . u i . TextFie ld ;

public class UserFie ldFactory extends Defau l tF i e ldFactory implements

FormFieldFactory {20

private stat ic f ina l St r ing COMMON FIELD WIDTH = ”12em” ;

private User datasource ;

private List<Organizat ion> orgs ;

public UserFie ldFactory ( Lis t<Organizat ion> orgs ) {datasource = null ;

this . o rgs = orgs ;

30 }

public UserFie ldFactory ( User user , L i s t<Organizat ion> orgs ) {datasource = user ;

this . o rgs = orgs ;

}

public Fie ld c r e a t e F i e l d ( Item item , Object propertyId , Component uiContext ) {Fie ld f = super . c r e a t e F i e l d ( item , propertyId , uiContext ) ;

i f ( ” user ” . equa l s ( propertyId ) ) {40 TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ”Username” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r the new username” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

t f . addVal idator (new Str ingLengthVal idator (

”Username must be 1−255 c h a r a c t e r s ” , 1 , 255 , fa l se ) ) ;

i f ( datasource != null )

t f . setValue ( datasource . getName ( ) ) ;

return t f ;

50 } else i f ( ”name” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ”Name” ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r name and surname” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

t f . addVal idator (new Str ingLengthVal idator (

”Name must be 1−255 c h a r a c t e r s ” , 1 , 255 , fa l se ) ) ;

i f ( datasource != null )

t f . setValue ( datasource . getName ( ) ) ;

538

Page 557: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

60 return t f ;

} else i f ( ”password” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ”Password” ) ;

t f . s e t S e c r e t ( true ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please ente r the password” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

t f . addVal idator (new Str ingLengthVal idator (

”Password must be 1−255 c h a r a c t e r s ” , 1 , 255 , fa l se ) ) ;

70 i f ( datasource != null )

t f . setValue ( datasource . getName ( ) ) ;

return t f ;

} else i f ( ” passwordcheck ” . equa l s ( propertyId ) ) {TextFie ld t f = ( TextFie ld ) f ;

t f . setCapt ion ( ”Password check ” ) ;

t f . s e t S e c r e t ( true ) ;

t f . s e tRequi red ( true ) ;

t f . s e tRequ i redError ( ” Please r e e n t e r the password” ) ;

t f . setWidth (COMMON FIELD WIDTH) ;

80 t f . addVal idator (new Str ingLengthVal idator (

”Password check must be 1−255 c h a r a c t e r s ” , 1 , 255 , fa l se ) ) ;

i f ( datasource != null )

t f . setValue ( datasource . getName ( ) ) ;

return t f ;

} else i f ( ” o r g a n i z a t i o n ” . equa l s ( propertyId ) ) {Nat iveSe l e c t n s e l = new Nat iveSe l e c t ( ) ;

n s e l . setCapt ion ( ” Organizat ion ” ) ;

BeanItemContainer<Organizat ion> ds = new BeanItemContainer<Organizat ion >(

orgs ) ;

90 n s e l . setContainerDataSource ( ds ) ;

n s e l . s e tNu l l S e l e c t i onA l l owed ( true ) ;

n s e l . se tRequi red ( fa l se ) ;

i f ( datasource != null ) {n s e l . s e l e c t ( datasource . ge tOrgan izat ion ( ) ) ;

n s e l . setValue ( datasource . ge tOrgan izat ion ( ) ) ;

}return n s e l ;

}return f ;

100 }

}

D.8 Package it.uniroma2.norge.web.support

D.8.1 Classe EvidenceMapBean.java

package i t . uniroma2 . norge . web . support ;

import i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e ;

import i t . uniroma2 . norge . model . jpa . De l ive rab l eEv idence ;

539

Page 558: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

import com . vaadin . t e rmina l . S i z e a b l e ;

import com . vaadin . u i . CheckBox ;

import com . vaadin . u i . TextFie ld ;

10 public class EvidenceMapBean {Del ive rab l eEv idence delEvid ;

D e l i v e r a b l e d e l i v e r a b l e ;

CheckBox yesno ;

S t r ing yesnoFlat ;

S t r ing addInfo ;

S t r ing comment ;

S t r ing ev idence ;

TextFie ld commentField ;

TextFie ld addIn foF ie ld ;

20 St r ing agreementStatus ;

public EvidenceMapBean ( f ina l Del ive rab l eEv idence de ) {setDelEvid ( de ) ;

s e t D e l i v e r a b l e ( de . g e t D e l i v e r a b l e ( ) ) ;

CheckBox c = new CheckBox ( ) ;

c . setValue ( fa l se ) ;

i f ( de != null ) {c . setValue ( de . ge t Inc luded ( ) ) ;

30 i f ( de . ge t Inc luded ( ) )

yesnoFlat = ”Yes” ;

else

yesnoFlat = ”No” ;

addInfo = de . g e t A d d i t i o n a l I n f o ( ) ;

comment = de . getApprovationComment ( ) ;

agreementStatus = de . getAnswsetAnsw ( ) . getApprovat ionDel ivStatus ( ) ;

}c . setImmediate ( true ) ;

setYesno ( c ) ;

40 setCommentField (new TextFie ld ( ) ) ;

s e tAddIn foFie ld (new TextFie ld ( ) ) ;

se tEvidence ( de . getAnswsetAnsw ( ) . getAlternat iveAnswer ( ) . getAnswer ( ) ) ;

comment = comment == null ? ”” : comment ;

getCommentField ( ) . setValue (comment ) ;

getCommentField ( ) . setWidth (12 , S i z e a b l e .UNITS EM) ;

addInfo = addInfo == null ? ”” : addInfo ;

getAddInfoFie ld ( ) . setValue ( addInfo ) ;

getAddInfoFie ld ( ) . setWidth (12 , S i z e a b l e .UNITS EM) ;

50 }

public CheckBox getYesno ( ) {return yesno ;

}

public void setYesno ( CheckBox yesno ) {this . yesno = yesno ;

}

60 public Del ive rab l eEv idence getDelEvid ( ) {

540

Page 559: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return delEvid ;

}

public void setDelEvid ( De l ive rab l eEv idence delEvid ) {this . de lEvid = delEvid ;

}

public St r ing getComment ( ) {return comment ;

70 }

public void setComment ( St r ing comment ) {this . comment = comment ;

}

public D e l i v e r a b l e g e t D e l i v e r a b l e ( ) {return d e l i v e r a b l e ;

}

80 public void s e t D e l i v e r a b l e ( D e l i v e r a b l e d e l i v e r a b l e ) {this . d e l i v e r a b l e = d e l i v e r a b l e ;

}

public TextFie ld getCommentField ( ) {return commentField ;

}

public void setCommentField ( TextFie ld commentField ) {this . commentField = commentField ;

90 }

public St r ing getEvidence ( ) {return ev idence ;

}

public void setEvidence ( S t r ing ev idence ) {this . ev idence = ev idence ;

}

100 public St r ing getAddInfo ( ) {return addInfo ;

}

public void setAddInfo ( S t r ing addInfo ) {this . addInfo = addInfo ;

}

public TextFie ld getAddInfoFie ld ( ) {return addIn foF ie ld ;

110 }

public void se tAddIn foFie ld ( TextFie ld addIn foF ie ld ) {this . addIn foF ie ld = addIn foF ie ld ;

}

public St r ing getAgreementStatus ( ) {

541

Page 560: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return agreementStatus ;

}

120 public void setAgreementStatus ( S t r ing agreementStatus ) {this . agreementStatus = agreementStatus ;

}

public St r ing getYesnoFlat ( ) {return yesnoFlat ;

}

public void setYesnoFlat ( S t r ing yesnoFlat ) {this . yesnoFlat = yesnoFlat ;

130 }

}

D.8.2 Classe ExclusionBean.java

package i t . uniroma2 . norge . web . support ;

public class ExclusionBean implements Comparable<ExclusionBean> {private St r ing d i r e c t i o n ;

private St r ing ques t i on ;

private St r ing answer ;

private St r ing t r i g g e r ;

public ExclusionBean ( St r ing quest ion , S t r ing answer , S t r ing t r i g g e r ,

10 St r ing d i r e c t i o n ) {super ( ) ;

this . ques t i on = ques t i on ;

this . answer = answer ;

this . t r i g g e r = t r i g g e r ;

this . d i r e c t i o n = d i r e c t i o n ;

}

public St r ing getQuest ion ( ) {return ques t i on ;

20 }

public void se tQuest ion ( S t r ing ques t i on ) {this . ques t i on = ques t i on ;

}

public St r ing getAnswer ( ) {return answer ;

}

30 public void setAnswer ( S t r ing answer ) {this . answer = answer ;

}

public St r ing ge tTr igge r ( ) {

542

Page 561: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return t r i g g e r ;

}

public void s e t T r i g g e r ( S t r ing t r i g g e r ) {this . t r i g g e r = t r i g g e r ;

40 }

public void s e t D i r e c t i o n ( S t r ing d i r e c t i o n ) {this . d i r e c t i o n = d i r e c t i o n ;

}

public St r ing g e t D i r e c t i o n ( ) {return d i r e c t i o n ;

}

50 @Override

public int compareTo ( ExclusionBean o ) {i f ( ge tTr igge r ( ) . compareTo ( o . ge tTr igge r ( ) ) != 0)

return −( ge tTr igge r ( ) . compareTo ( o . ge tTr igge r ( ) ) ) ;

i f ( g e t D i r e c t i o n ( ) . compareTo ( o . g e t D i r e c t i o n ( ) ) != 0)

return ( g e t D i r e c t i o n ( ) . compareTo ( o . g e t D i r e c t i o n ( ) ) ) ;

i f ( getQuest ion ( ) . compareTo ( o . getQuest ion ( ) ) != 0)

return ( getQuest ion ( ) . compareTo ( o . getQuest ion ( ) ) ) ;

return ( getAnswer ( ) . compareTo ( o . getAnswer ( ) ) ) ;

}60 }

D.8.3 Classe FillingBean.java

package i t . uniroma2 . norge . web . support ;

import i t . uniroma2 . norge . model . jpa . Evidence ;

import java . u t i l . ArrayList ;

import com . vaadin . data . Property ;

import com . vaadin . data . Property . ValueChangeEvent ;

import com . vaadin . u i . Button ;

10 import com . vaadin . u i . CheckBox ;

public class Fi l l i ngBean {Evidence answsetAnsw ;

int answsetAnswId ;

int answerId ;

S t r ing answer ;

CheckBox yesno ;

Button r u l e s ;

S t r ing approvat ion ;

20 ArrayList<Fi l l ingBean> c h i l d r e n ;

public Fi l l i ngBean ( f ina l Evidence a ) {c h i l d r e n = new ArrayList<Fi l l ingBean >() ;

setAnswsetAnsw ( a ) ;

543

Page 562: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

setAnswsetAnswId ( a . getAnswsetAnswId ( ) ) ;

setAnswerId ( a . getAlternat iveAnswer ( ) . getAnswerId ( ) ) ;

setAnswer ( a . getAlternat iveAnswer ( ) . getAnswer ( ) ) ;

CheckBox c = new CheckBox ( ) ;

30 i f ( a . getResponse ( ) . toLowerCase ( ) . equa l s ( ” yes ” ) ) {setApprovat ion ( a . getApprovat ionStatus ( ) ) ;

c . setValue ( true ) ;

}c . setImmediate ( true ) ;

setYesno ( c ) ;

Button b = new Button ( ”−>” ) ;

b . setImmediate ( true ) ;

s e tRu l e s (b) ;

getYesno ( ) . addLis tener (new Property . ValueChangeListener ( ) {40 @Override

public void valueChange ( ValueChangeEvent event ) {Fi l l i ngBean . this . enab leChi ldren ( ) ;

}}) ;

}

public void enab leChi ldren ( ) {i f ( c h i l d r e n . s i z e ( ) > 0) {

boolean tmp = fa l se ;

50 i f ( getYesno ( ) . i sEnabled ( )

&& ( Boolean ) ( getYesno ( ) . getValue ( ) ) == true )

tmp = true ;

for ( F i l l i ngBean c : c h i l d r e n ) {c . getYesno ( ) . setEnabled (tmp) ;

}}

}

public void i n i t C h i l d r e n ( ) {60 for ( F i l l i ngBean c : c h i l d r e n )

c . getYesno ( ) . setEnabled ( true ) ;

i f ( ! getYesno ( ) . i sEnabled ( )

| | ( Boolean ) ( getYesno ( ) . getValue ( ) ) != true )

for ( F i l l i ngBean c : c h i l d r e n )

c . getYesno ( ) . setEnabled ( fa l se ) ;

}

public void addChild ( F i l l i ngBean c ) {c h i l d r e n . add ( c ) ;

70 }

public Evidence getAnswsetAnswCommitted ( ) {i f ( ( ( Boolean ) yesno . getValue ( ) ) == fa l se )

answsetAnsw . setResponse ( ”no” ) ;

else

answsetAnsw . setResponse ( ” yes ” ) ;

return answsetAnsw ;

}

80 public St r ing getAnswer ( ) {return answer ;

544

Page 563: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

public void setAnswer ( S t r ing answer ) {this . answer = answer ;

}

public CheckBox getYesno ( ) {return yesno ;

90 }

public void setYesno ( CheckBox yesno ) {this . yesno = yesno ;

}

public Button getRules ( ) {return r u l e s ;

}

100 public void s e tRu l e s ( Button r u l e s ) {this . r u l e s = r u l e s ;

}

public St r ing getApprovation ( ) {return approvat ion ;

}

public void setApprovat ion ( S t r ing s t r i n g ) {this . approvat ion = s t r i n g ;

110 }

public int getAnswerId ( ) {return answerId ;

}

public void setAnswerId ( int answerId ) {this . answerId = answerId ;

}120

public int getAnswsetAnswId ( ) {return answsetAnswId ;

}

public void setAnswsetAnswId ( int answsetAnswId ) {this . answsetAnswId = answsetAnswId ;

}

public Evidence getAnswsetAnsw ( ) {130 return answsetAnsw ;

}

public void setAnswsetAnsw ( Evidence answsetAnsw ) {this . answsetAnsw = answsetAnsw ;

}

}

545

Page 564: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.8.4 Classe MenuLinks.java

package i t . uniroma2 . norge . web . support ;

public f ina l class MenuLinks {public stat ic f ina l St r ing VIEW ALL = ”View a l l ” ;

public stat ic f ina l St r ing FILLING = ” F i l l i n g−out” ;

public stat ic f ina l St r ing DOCUMENTS = ”Documents” ;

public stat ic f ina l St r ing VALIDATION = ” Val idat i on ” ;

public stat ic f ina l St r ing DELIVERABLE CHECK = ” D e l i v e r a b l e s ” ;

public stat ic f ina l St r ing DELIVERABLE VALIDATION = ” D e l i v e r a b l e s ” ;

10 }

D.8.5 Classe StringBean.java

package i t . uniroma2 . norge . web . support ;

public class StringBean {

private St r ing s t r i n g ;

public StringBean ( ) {}

10 public St r ing g e t S t r i n g ( ) {return s t r i n g ;

}

public void s e t S t r i n g ( S t r ing s t r i n g ) {this . s t r i n g = s t r i n g ;

}

20 }

D.8.6 Classe ValidationBean.java

package i t . uniroma2 . norge . web . support ;

import i t . uniroma2 . norge . common . AnswerStatus ;

import i t . uniroma2 . norge . model . jpa . Evidence ;

import java . u t i l . ArrayList ;

import com . vaadin . u i . Nat i v eSe l e c t ;

10 public class Validat ionBean {Evidence answsetAnsw ;

int answsetAnswId ;

int answerId ;

546

Page 565: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

St r ing answer ;

S t r ing yesno ;

Nat iv eSe l e c t approvat ion ;

ArrayList<ValidationBean> c h i l d r e n ;

private Validat ionBean parent ;

20 private St r ing [ ] poss = new St r ing [ ] { AnswerStatus .PROPOSED,

AnswerStatus .ACCEPTED, AnswerStatus .PART AGREED,

AnswerStatus .REJECTED } ;

public Validat ionBean ( f ina l Evidence a ) {c h i l d r e n = new ArrayList<ValidationBean >() ;

setAnswsetAnsw ( a ) ;

setAnswsetAnswId ( a . getAnswsetAnswId ( ) ) ;

setAnswerId ( a . getAlternat iveAnswer ( ) . getAnswerId ( ) ) ;

setAnswer ( a . getAlternat iveAnswer ( ) . getAnswer ( ) ) ;

30 St r ing r = a . getResponse ( ) . toLowerCase ( ) ;

i f ( r == null | | r . equa l s ( ”” ) )

r = ”no” ;

setYesno ( r ) ;

i f ( r . equa l s ( ” yes ” ) ) {Nat iveSe l e c t c = new Nat iveSe l e c t ( ) ;

c . setNewItemsAllowed ( fa l se ) ;

c . s e tNu l l S e l e c t i onA l l owed ( fa l se ) ;

for ( int i = 0 ; i < poss . l ength ; i++) {c . addItem ( poss [ i ] ) ;

40 }i f ( a . getApprovat ionStatus ( ) . equa l s ( ”” ) ) {

c . setValue ( poss [ 0 ] ) ;

c . s e l e c t ( poss [ 0 ] ) ;

} else {for ( int i = 0 ; i < poss . l ength ; i++)

i f ( a . getApprovat ionStatus ( ) . equa l s IgnoreCase ( poss [ i ] ) ) {c . setValue ( a . getApprovat ionStatus ( ) . toLowerCase ( ) ) ;

c . s e l e c t ( poss [ i ] ) ;

}50 }

setApprovat ion ( c ) ;

}}

public void addChild ( Val idat ionBean c ) {c h i l d r e n . add ( c ) ;

c . se tParent ( this ) ;

}

60 private void se tParent ( Val idat ionBean c ) {parent = c ;

}

public Evidence getAnswsetAnswCommitted ( ) {St r ing tmp ;

i f ( approvat ion != null ) {tmp = ( St r ing ) approvat ion . getValue ( ) ;

answsetAnsw . setApprovat ionStatus (tmp) ;

}

547

Page 566: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

70 return answsetAnsw ;

}

public St r ing getAnswer ( ) {return answer ;

}

public void setAnswer ( S t r ing answer ) {this . answer = answer ;

}80

public St r ing getYesno ( ) {return yesno ;

}

public void setYesno ( S t r ing yesno ) {this . yesno = yesno ;

}

public Nat iveSe l e c t getApprovation ( ) {90 i f ( parent == null )

return approvat ion ;

return null ;

}

public void setApprovat ion ( Nat i v eSe l e c t s t r i n g ) {this . approvat ion = s t r i n g ;

}

100 public int getAnswerId ( ) {return answerId ;

}

public void setAnswerId ( int answerId ) {this . answerId = answerId ;

}

public int getAnswsetAnswId ( ) {return answsetAnswId ;

110 }

public void setAnswsetAnswId ( int answsetAnswId ) {this . answsetAnswId = answsetAnswId ;

}

public Evidence getAnswsetAnsw ( ) {return answsetAnsw ;

}

120 public void setAnswsetAnsw ( Evidence answsetAnsw ) {this . answsetAnsw = answsetAnsw ;

}}

548

Page 567: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.9 Package it.uniroma2.norge.web.widgetset

D.9.1 File TesiwebappWidgetset.gwt.xml

<?xml version=” 1 .0 ” encoding=”UTF−8”?>

< !DOCTYPE module PUBLIC ”−//Google Inc . //DTD Google Web Too lk i t 1 . 7 . 0 / /EN”

” ht tp : // google−web−t o o l k i t . goog lecode . com/svn/ tags / 1 . 7 . 0 / d i s t r o−source / core / s r c /gwt−module . dtd”>

<module>

< i n h e r i t s name=”com . vaadin . t e rmina l . gwt . DefaultWidgetSet ” />

< !−− <set−property name=” user . agent ” value=” gecko ”/> −−>< i n h e r i t s name=”com . vaadin . addon . t r e e t a b l e . TreetableWidgetset ” />

</module>

D.10 Package it.jaxb.ecore

D.10.1 Classe Details.java

package i t . jaxb . e co re ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlRootElement ;

import javax . xml . bind . annotat ion . XmlSchemaType ;

10 import javax . xml . bind . annotat ion . XmlType ;

import javax . xml . bind . annotat ion . adapters . Col lapsedStr ingAdapter ;

import javax . xml . bind . annotat ion . adapters . XmlJavaTypeAdapter ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” )

@XmlRootElement (name = ” d e t a i l s ” )

public class D e t a i l s {

20 @XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

protected St r ing key ;

@XmlAttribute ( r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing value ;

public St r ing getKey ( ) {return key ;

30 }

public void setKey ( St r ing value ) {this . key = value ;

}

549

Page 568: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public St r ing getValue ( ) {return value ;

}

40 public void setValue ( S t r ing value ) {this . va lue = value ;

}

}

D.10.2 Classe EAnnotations.java

package i t . jaxb . e co re ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlElement ;

import javax . xml . bind . annotat ion . XmlRootElement ;

10 import javax . xml . bind . annotat ion . XmlSchemaType ;

import javax . xml . bind . annotat ion . XmlType ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” , propOrder = {” d e t a i l s ”

})

@XmlRootElement (name = ” eAnnotat ions ” )

public class EAnnotations {20

@XmlElement ( r equ i r ed = true )

protected D e t a i l s d e t a i l s ;

@XmlAttribute ( r equ i r ed = true )

@XmlSchemaType(name = ”anyURI” )

protected St r ing source ;

public D e t a i l s g e t D e t a i l s ( ) {return d e t a i l s ;

}30

public void s e t D e t a i l s ( D e t a i l s va lue ) {this . d e t a i l s = value ;

}

public St r ing getSource ( ) {return source ;

}

public void s e tSource ( S t r ing value ) {40 this . source = value ;

}

550

Page 569: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

D.10.3 Classe EClassifiers.java

package i t . jaxb . e co re ;

import java . u t i l . ArrayList ;

import java . u t i l . L i s t ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

10 import javax . xml . bind . annotat ion . XmlRootElement ;

import javax . xml . bind . annotat ion . XmlSchemaType ;

import javax . xml . bind . annotat ion . XmlType ;

import javax . xml . bind . annotat ion . adapters . Col lapsedStr ingAdapter ;

import javax . xml . bind . annotat ion . adapters . XmlJavaTypeAdapter ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” , propOrder = {” eAnnotations ” ,

20 ” e L i t e r a l s ” ,

” eOperat ions ” ,

” eS t ruc tu ra lFea tu r e s ”

})

@XmlRootElement (name = ” e C l a s s i f i e r s ” )

public class E C l a s s i f i e r s {

protected EAnnotations eAnnotat ions ;

protected List<ELi te ra l s> e L i t e r a l s ;

protected EOperations eOperat ions ;

30 protected List<EStructura lFeatures> eS t ruc tu ra lFea tu r e s ;

@XmlAttribute

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing eSuperTypes ;

@XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

protected St r ing name ;

@XmlAttribute (name = ” x s i t y p e ” )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

40 @XmlSchemaType(name = ”NMTOKEN” )

protected St r ing xsiType ;

@XmlAttribute ( namespace = ”INST” )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NMTOKEN” )

protected St r ing type ;

public EAnnotations getEAnnotations ( ) {return eAnnotat ions ;

}

551

Page 570: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

50public void setEAnnotat ions ( EAnnotations va lue ) {

this . eAnnotat ions = value ;

}

public List<ELi te ra l s> g e t E L i t e r a l s ( ) {i f ( e L i t e r a l s == null ) {

e L i t e r a l s = new ArrayList<ELi te ra l s >() ;

}return this . e L i t e r a l s ;

60 }

public EOperations getEOperations ( ) {return eOperat ions ;

}

public void setEOperat ions ( EOperations va lue ) {this . eOperat ions = value ;

}

70 public List<EStructura lFeatures> getEStruc tura lFeature s ( ) {i f ( eS t ruc tu ra lFea tu r e s == null ) {

eS t ruc tu ra lFea tu r e s = new ArrayList<EStructura lFeatures >() ;

}return this . eS t ruc tu ra lFea tu r e s ;

}

public St r ing getESuperTypes ( ) {return eSuperTypes ;

}80

public void setESuperTypes ( S t r ing value ) {this . eSuperTypes = value ;

}

public St r ing getName ( ) {return name ;

}

public void setName ( St r ing value ) {90 this . name = value ;

}

public St r ing getXsiType ( ) {return xsiType ;

}

public void setXsiType ( S t r ing value ) {this . xsiType = value ;

}100

public St r ing getType ( ) {return type ;

}

public void setType ( S t r ing value ) {

552

Page 571: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

this . type = value ;

}

}

D.10.4 Classe ELiterals.java

package i t . jaxb . e co re ;

import java . math . B ig In tege r ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlRootElement ;

10 import javax . xml . bind . annotat ion . XmlSchemaType ;

import javax . xml . bind . annotat ion . XmlType ;

import javax . xml . bind . annotat ion . adapters . Col lapsedStr ingAdapter ;

import javax . xml . bind . annotat ion . adapters . XmlJavaTypeAdapter ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” )

@XmlRootElement (name = ” e L i t e r a l s ” )

public class E L i t e r a l s {20

@XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

protected St r ing name ;

@XmlAttribute

protected Big Intege r va lue ;

public St r ing getName ( ) {return name ;

30 }

public void setName ( St r ing value ) {this . name = value ;

}

public Big Intege r getValue ( ) {return value ;

}

40 public void setValue ( B ig Intege r va lue ) {this . va lue = value ;

}

}

553

Page 572: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.10.5 Classe EOperations.java

package i t . jaxb . e co re ;

import java . math . B ig In tege r ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlRootElement ;

10 import javax . xml . bind . annotat ion . XmlSchemaType ;

import javax . xml . bind . annotat ion . XmlType ;

import javax . xml . bind . annotat ion . adapters . Col lapsedStr ingAdapter ;

import javax . xml . bind . annotat ion . adapters . XmlJavaTypeAdapter ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” )

@XmlRootElement (name = ” eOperat ions ” )

public class EOperations {20

@XmlAttribute ( r equ i r ed = true )

protected Big Intege r lowerBound ;

@XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

protected St r ing name ;

@XmlAttribute ( r equ i r ed = true )

protected boolean ordered ;

30 public Big Intege r getLowerBound ( ) {return lowerBound ;

}

public void setLowerBound ( Big Intege r va lue ) {this . lowerBound = value ;

}

public St r ing getName ( ) {return name ;

40 }

public void setName ( St r ing value ) {this . name = value ;

}

public boolean i sOrdered ( ) {return ordered ;

}

50 public void setOrdered (boolean value ) {this . ordered = value ;

}

}

554

Page 573: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.10.6 Classe EPackage.java

package i t . jaxb . e co re ;

import java . math . BigDecimal ;

import java . u t i l . ArrayList ;

import java . u t i l . L i s t ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

10 import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlElement ;

import javax . xml . bind . annotat ion . XmlRootElement ;

import javax . xml . bind . annotat ion . XmlSchemaType ;

import javax . xml . bind . annotat ion . XmlType ;

import javax . xml . bind . annotat ion . adapters . Col lapsedStr ingAdapter ;

import javax . xml . bind . annotat ion . adapters . XmlJavaTypeAdapter ;

@XmlAccessorType ( XmlAccessType . FIELD)

20 @XmlType(name = ”” , propOrder = {” eSubpackages ”

})

@XmlRootElement (name = ”EPackage” , namespace =

” http ://www. e c l i p s e . org /emf /2002/ Ecore ” )

public class EPackage {

@XmlElement ( r equ i r ed = true )

protected List<ESubpackages> eSubpackages ;

@XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

30 @XmlSchemaType(name = ”NCName” )

protected St r ing name ;

@XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

protected St r ing nsPre f i x ;

@XmlAttribute ( r equ i r ed = true )

@XmlSchemaType(name = ”anyURI” )

protected St r ing nsURI ;

@XmlAttribute ( namespace = ” http ://www. omg . org /XMI” , r equ i r ed = true )

40 protected BigDecimal v e r s i on ;

public List<ESubpackages> getESubpackages ( ) {i f ( eSubpackages == null ) {

eSubpackages = new ArrayList<ESubpackages >() ;

}return this . eSubpackages ;

}

public St r ing getName ( ) {50 return name ;

}

public void setName ( St r ing value ) {

555

Page 574: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

this . name = value ;

}

public St r ing getNsPre f ix ( ) {return nsPre f i x ;

}60

public void s e tNsPre f i x ( S t r ing value ) {this . n sPre f i x = value ;

}

public St r ing getNsURI ( ) {return nsURI ;

}

public void setNsURI ( St r ing value ) {70 this . nsURI = value ;

}

public BigDecimal getVers ion ( ) {return ve r s i o n ;

}

public void s e tVer s i on ( BigDecimal va lue ) {this . v e r s i on = value ;

}80}

D.10.7 Classe EStructuralFeatures.java

package i t . jaxb . e co re ;

import java . math . B ig In tege r ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlRootElement ;

10 import javax . xml . bind . annotat ion . XmlSchemaType ;

import javax . xml . bind . annotat ion . XmlType ;

import javax . xml . bind . annotat ion . adapters . Col lapsedStr ingAdapter ;

import javax . xml . bind . annotat ion . adapters . XmlJavaTypeAdapter ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” , propOrder = {” eAnnotations ”

})

20 @XmlRootElement (name = ” eSt ruc tu ra lFea tu r e s ” )

public class EStructura lFeatures {

protected EAnnotations eAnnotat ions ;

556

Page 575: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@XmlAttribute

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing eOpposite ;

@XmlAttribute

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing eType ;

30 @XmlAttribute

protected Big Intege r lowerBound ;

@XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

protected St r ing name ;

@XmlAttribute ( r equ i r ed = true )

protected boolean ordered ;

@XmlAttribute

protected Big Intege r upperBound ;

40 @XmlAttribute (name = ” x s i t y p e ” )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NMTOKEN” )

protected St r ing xsiType ;

@XmlAttribute ( namespace = ”INST” )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NMTOKEN” )

protected St r ing type ;

public EAnnotations getEAnnotations ( ) {50 return eAnnotat ions ;

}

public void setEAnnotat ions ( EAnnotations va lue ) {this . eAnnotat ions = value ;

}

public St r ing getEOpposite ( ) {return eOpposite ;

}60

public void setEOpposite ( S t r ing value ) {this . eOpposite = value ;

}

public St r ing getEType ( ) {return eType ;

}

public void setEType ( S t r ing value ) {70 this . eType = value ;

}

public Big Intege r getLowerBound ( ) {return lowerBound ;

}

public void setLowerBound ( Big Intege r va lue ) {this . lowerBound = value ;

}

557

Page 576: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

80public St r ing getName ( ) {

return name ;

}

public void setName ( St r ing value ) {this . name = value ;

}

public boolean i sOrdered ( ) {90 return ordered ;

}

public void setOrdered (boolean value ) {this . ordered = value ;

}

public Big Intege r getUpperBound ( ) {return upperBound ;

}100

public void setUpperBound ( Big Intege r va lue ) {this . upperBound = value ;

}

public St r ing getXsiType ( ) {return xsiType ;

}

public void setXsiType ( S t r ing value ) {110 this . xsiType = value ;

}

public St r ing getType ( ) {return type ;

}

public void setType ( S t r ing value ) {this . type = value ;

}120

}

D.10.8 Classe ESubpackages.java

package i t . jaxb . e co re ;

import java . u t i l . ArrayList ;

import java . u t i l . L i s t ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

558

Page 577: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

10 import javax . xml . bind . annotat ion . XmlRootElement ;

import javax . xml . bind . annotat ion . XmlSchemaType ;

import javax . xml . bind . annotat ion . XmlType ;

import javax . xml . bind . annotat ion . adapters . Col lapsedStr ingAdapter ;

import javax . xml . bind . annotat ion . adapters . XmlJavaTypeAdapter ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” , propOrder = {” eSubpackages ” ,

20 ” e C l a s s i f i e r s ”

})

@XmlRootElement (name = ” eSubpackages ” )

public class ESubpackages {

protected ESubpackages eSubpackages ;

protected List<E C l a s s i f i e r s > e C l a s s i f i e r s ;

@XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

30 protected St r ing name ;

@XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

protected St r ing nsPre f i x ;

@XmlAttribute ( r equ i r ed = true )

@XmlSchemaType(name = ”anyURI” )

protected St r ing nsURI ;

public ESubpackages getESubpackages ( ) {40 return eSubpackages ;

}

public void setESubpackages ( ESubpackages va lue ) {this . eSubpackages = value ;

}

public List<E C l a s s i f i e r s > g e t E C l a s s i f i e r s ( ) {i f ( e C l a s s i f i e r s == null ) {

e C l a s s i f i e r s = new ArrayList<E C l a s s i f i e r s >() ;

50 }return this . e C l a s s i f i e r s ;

}

public St r ing getName ( ) {return name ;

}

public void setName ( St r ing value ) {this . name = value ;

60 }

public St r ing getNsPre f ix ( ) {return nsPre f i x ;

}

559

Page 578: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public void s e tNsPre f i x ( S t r ing value ) {this . n sPre f i x = value ;

}

70 public St r ing getNsURI ( ) {return nsURI ;

}

public void setNsURI ( St r ing value ) {this . nsURI = value ;

}

}

D.10.9 Classe ObjectFactory.java

package i t . jaxb . e co re ;

import javax . xml . bind . annotat ion . XmlRegistry ;

@XmlRegistry

public class ObjectFactory {10

public ObjectFactory ( ) {}

public E L i t e r a l s c r e a t e E L i t e r a l s ( ) {return new E L i t e r a l s ( ) ;

}

public EPackage createEPackage ( ) {20 return new EPackage ( ) ;

}

public EAnnotations createEAnnotat ions ( ) {return new EAnnotations ( ) ;

}

public D e t a i l s c r e a t e D e t a i l s ( ) {return new D e t a i l s ( ) ;

}30

public E C l a s s i f i e r s c r e a t e E C l a s s i f i e r s ( ) {return new E C l a s s i f i e r s ( ) ;

}

public EStructura lFeatures c r ea t eESt ruc tu ra lFea tu r e s ( ) {return new EStructura lFeatures ( ) ;

}

560

Page 579: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public ESubpackages createESubpackages ( ) {40 return new ESubpackages ( ) ;

}

public EOperations createEOperat ions ( ) {return new EOperations ( ) ;

}

}

D.11 Package it.jaxb.ecorediag

D.11.1 Classe Bendpoints.java

package i t . jaxb . e co r ed i ag ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlRootElement ;

import javax . xml . bind . annotat ion . XmlSchemaType ;

10 import javax . xml . bind . annotat ion . XmlType ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” )

@XmlRootElement (name = ” bendpoints ” )

public class Bendpoints {

@XmlAttribute ( r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

20 protected St r ing po in t s ;

@XmlAttribute (name = ” xmi id ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing xmiId ;

@XmlAttribute (name = ” xmi type ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing xmiType ;

public St r ing getPo int s ( ) {return po in t s ;

30 }

public void s e tPo in t s ( S t r ing value ) {this . po in t s = value ;

}

public St r ing getXmiId ( ) {return xmiId ;

}

561

Page 580: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

40 public void setXmiId ( S t r ing value ) {this . xmiId = value ;

}

public St r ing getXmiType ( ) {return xmiType ;

}

public void setXmiType ( St r ing value ) {this . xmiType = value ;

50 }

}

D.11.2 Classe Children.java

package i t . jaxb . e co r ed i ag ;

import java . math . B ig In tege r ;

import java . u t i l . ArrayList ;

import java . u t i l . L i s t ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

10 import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlRootElement ;

import javax . xml . bind . annotat ion . XmlSchemaType ;

import javax . xml . bind . annotat ion . XmlType ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” , propOrder = {” c h i l d r e n ” ,

” s t y l e s ” ,

20 ” element ” ,

” layoutConst ra in t ”

})

@XmlRootElement (name = ” c h i l d r e n ” )

public class Chi ldren {

protected List<Children> c h i l d r e n ;

protected List<Sty l e s> s t y l e s ;

protected Element element ;

protected LayoutConstraint l ayoutConst ra in t ;

30 @XmlAttribute (name = ” type ” , r equ i r ed = true )

protected Big Intege r chi ldrenType ;

@XmlAttribute (name = ” xmi id ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing xmiId ;

@XmlAttribute (name = ” xmi type ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing xmiType ;

562

Page 581: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public List<Children> getChi ldren ( ) {40 i f ( c h i l d r e n == null ) {

c h i l d r e n = new ArrayList<Children >() ;

}return this . c h i l d r e n ;

}

public List<Sty l e s> g e t S t y l e s ( ) {i f ( s t y l e s == null ) {

s t y l e s = new ArrayList<Sty l e s >() ;

}50 return this . s t y l e s ;

}

public Element getElement ( ) {return element ;

}

public void setElement ( Element value ) {this . e lement = value ;

}60

public LayoutConstraint getLayoutConstra int ( ) {return l ayoutConst ra in t ;

}

public void setLayoutConstra int ( LayoutConstraint va lue ) {this . l ayoutConst ra in t = value ;

}

public Big Intege r getChildrenType ( ) {70 return chi ldrenType ;

}

public void setChi ldrenType ( B ig Intege r va lue ) {this . ch i ldrenType = value ;

}

public St r ing getXmiId ( ) {return xmiId ;

}80

public void setXmiId ( S t r ing value ) {this . xmiId = value ;

}

public St r ing getXmiType ( ) {return xmiType ;

}

public void setXmiType ( St r ing value ) {90 this . xmiType = value ;

}

}

563

Page 582: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.11.3 Classe Details.java

package i t . jaxb . e co r ed i ag ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlRootElement ;

import javax . xml . bind . annotat ion . XmlSchemaType ;

10 import javax . xml . bind . annotat ion . XmlType ;

import javax . xml . bind . annotat ion . adapters . Col lapsedStr ingAdapter ;

import javax . xml . bind . annotat ion . adapters . XmlJavaTypeAdapter ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” )

@XmlRootElement (name = ” d e t a i l s ” )

public class D e t a i l s {

20 @XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NMTOKEN” )

protected St r ing key ;

@XmlAttribute (name = ” xmi id ” , r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NMTOKEN” )

protected St r ing xmiId ;

@XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

30 @XmlSchemaType(name = ”NMTOKEN” )

protected St r ing value ;

@XmlAttribute (name = ” xmi type ” , r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NMTOKEN” )

protected St r ing xmiType ;

public St r ing getKey ( ) {return key ;

}40

public void setKey ( St r ing value ) {this . key = value ;

}

public St r ing getXmiId ( ) {return xmiId ;

}

public void setXmiId ( S t r ing value ) {50 this . xmiId = value ;

}

public St r ing getValue ( ) {return value ;

564

Page 583: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

public void setValue ( S t r ing value ) {this . va lue = value ;

}60

public St r ing getXmiType ( ) {return xmiType ;

}

public void setXmiType ( St r ing value ) {this . xmiType = value ;

}

}

D.11.4 Classe Diagram.java

package i t . jaxb . e co r ed i ag ;

import java . math . BigDecimal ;

import java . u t i l . ArrayList ;

import java . u t i l . L i s t ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

10 import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlElement ;

import javax . xml . bind . annotat ion . XmlRootElement ;

import javax . xml . bind . annotat ion . XmlSchemaType ;

import javax . xml . bind . annotat ion . XmlType ;

import javax . xml . bind . annotat ion . adapters . Col lapsedStr ingAdapter ;

import javax . xml . bind . annotat ion . adapters . XmlJavaTypeAdapter ;

@XmlAccessorType ( XmlAccessType . FIELD)

20 @XmlType(name = ”” , propOrder = {” c h i l d r e n ” ,

” s t y l e s ” ,

” element ” ,

” edges ”

})

@XmlRootElement (name = ”Diagram” , namespace =

” http ://www. e c l i p s e . org /gmf/ runtime / 1 . 0 . 2 / notat ion ” )

public class Diagram {

@XmlElement ( r equ i r ed = true )

30 protected List<Children> c h i l d r e n ;

@XmlElement ( r equ i r ed = true )

protected S t y l e s s t y l e s ;

@XmlElement ( r equ i r ed = true )

protected Element element ;

@XmlElement ( r equ i r ed = true )

565

Page 584: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

protected List<Edges> edges ;

@XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

40 protected St r ing measurementUnit ;

@XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

protected St r ing name ;

@XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

protected St r ing type ;

@XmlAttribute ( namespace = ” http ://www. omg . org /XMI” , r equ i r ed = true )

50 @XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

protected St r ing id ;

@XmlAttribute ( namespace = ” http ://www. omg . org /XMI” , r equ i r ed = true )

protected BigDecimal v e r s i on ;

public List<Children> getChi ldren ( ) {i f ( c h i l d r e n == null ) {

c h i l d r e n = new ArrayList<Children >() ;

}60 return this . c h i l d r e n ;

}

public S t y l e s g e t S t y l e s ( ) {return s t y l e s ;

}

public void s e t S t y l e s ( S t y l e s va lue ) {this . s t y l e s = value ;

}70

public Element getElement ( ) {return element ;

}

public void setElement ( Element value ) {this . e lement = value ;

}

public List<Edges> getEdges ( ) {80 i f ( edges == null ) {

edges = new ArrayList<Edges>() ;

}return this . edges ;

}

public St r ing getMeasurementUnit ( ) {return measurementUnit ;

}

90 public void setMeasurementUnit ( S t r ing value ) {this . measurementUnit = value ;

566

Page 585: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

public St r ing getName ( ) {return name ;

}

public void setName ( St r ing value ) {this . name = value ;

100 }

public St r ing getType ( ) {return type ;

}

public void setType ( S t r ing value ) {this . type = value ;

}

110 public St r ing get Id ( ) {return id ;

}

public void s e t I d ( S t r ing value ) {this . id = value ;

}

public BigDecimal getVers ion ( ) {return ve r s i o n ;

120 }

public void s e tVer s i on ( BigDecimal va lue ) {this . v e r s i on = value ;

}

}

D.11.5 Classe EAnnotations.java

package i t . jaxb . e co r ed i ag ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlElement ;

import javax . xml . bind . annotat ion . XmlRootElement ;

10 import javax . xml . bind . annotat ion . XmlSchemaType ;

import javax . xml . bind . annotat ion . XmlType ;

import javax . xml . bind . annotat ion . adapters . Col lapsedStr ingAdapter ;

import javax . xml . bind . annotat ion . adapters . XmlJavaTypeAdapter ;

@XmlAccessorType ( XmlAccessType . FIELD)

567

Page 586: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@XmlType(name = ”” , propOrder = {” d e t a i l s ”

})

20 @XmlRootElement (name = ” eAnnotat ions ” )

public class EAnnotations {

@XmlElement ( r equ i r ed = true )

protected D e t a i l s d e t a i l s ;

@XmlAttribute (name = ” xmi id ” , r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NMTOKEN” )

protected St r ing xmiId ;

@XmlAttribute ( r equ i r ed = true )

30 protected St r ing source ;

@XmlAttribute (name = ” xmi type ” , r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NMTOKEN” )

protected St r ing xmiType ;

public D e t a i l s g e t D e t a i l s ( ) {return d e t a i l s ;

}

40 public void s e t D e t a i l s ( D e t a i l s va lue ) {this . d e t a i l s = value ;

}

public St r ing getXmiId ( ) {return xmiId ;

}

public void setXmiId ( S t r ing value ) {this . xmiId = value ;

50 }

public St r ing getSource ( ) {return source ;

}

public void s e tSource ( S t r ing value ) {this . source = value ;

}

60 public St r ing getXmiType ( ) {return xmiType ;

}

public void setXmiType ( St r ing value ) {this . xmiType = value ;

}

}

568

Page 587: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.11.6 Classe Edges.java

package i t . jaxb . e co r ed i ag ;

import java . math . B ig In tege r ;

import java . u t i l . ArrayList ;

import java . u t i l . L i s t ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

10 import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlElement ;

import javax . xml . bind . annotat ion . XmlRootElement ;

import javax . xml . bind . annotat ion . XmlSchemaType ;

import javax . xml . bind . annotat ion . XmlType ;

import javax . xml . bind . annotat ion . adapters . Col lapsedStr ingAdapter ;

import javax . xml . bind . annotat ion . adapters . XmlJavaTypeAdapter ;

@XmlAccessorType ( XmlAccessType . FIELD)

20 @XmlType(name = ”” , propOrder = {” c h i l d r e n ” ,

” s t y l e s ” ,

” element ” ,

” bendpoints ” ,

” sourceAnchor ” ,

” targetAnchor ”

})

@XmlRootElement (name = ” edges ” )

public class Edges {30

protected List<Children> c h i l d r e n ;

@XmlElement ( r equ i r ed = true )

protected List<Sty l e s> s t y l e s ;

@XmlElement ( r equ i r ed = true )

protected Element element ;

@XmlElement ( r equ i r ed = true )

protected Bendpoints bendpoints ;

protected SourceAnchor sourceAnchor ;

protected TargetAnchor targetAnchor ;

40 @XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

protected St r ing source ;

@XmlAttribute ( r equ i r ed = true )

@XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

protected St r ing t a r g e t ;

@XmlAttribute (name = ” type ” , r equ i r ed = true )

protected Big Intege r edgesId ;

50 @XmlAttribute (name = ” xmi id ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing xmiId ;

@XmlAttribute (name = ” xmi type ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

569

Page 588: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

protected St r ing xmiType ;

public List<Children> getChi ldren ( ) {i f ( c h i l d r e n == null ) {

c h i l d r e n = new ArrayList<Children >() ;

60 }return this . c h i l d r e n ;

}

public List<Sty l e s> g e t S t y l e s ( ) {i f ( s t y l e s == null ) {

s t y l e s = new ArrayList<Sty l e s >() ;

}return this . s t y l e s ;

}70

public Element getElement ( ) {return element ;

}

public void setElement ( Element value ) {this . e lement = value ;

}

public Bendpoints getBendpoints ( ) {80 return bendpoints ;

}

public void setBendpoints ( Bendpoints va lue ) {this . bendpoints = value ;

}

public SourceAnchor getSourceAnchor ( ) {return sourceAnchor ;

}90

public void setSourceAnchor ( SourceAnchor value ) {this . sourceAnchor = value ;

}

public TargetAnchor getTargetAnchor ( ) {return targetAnchor ;

}

public void setTargetAnchor ( TargetAnchor value ) {100 this . targetAnchor = value ;

}

public St r ing getSource ( ) {return source ;

}

public void s e tSource ( S t r ing value ) {this . source = value ;

}110

570

Page 589: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

public St r ing getTarget ( ) {return t a r g e t ;

}

public void se tTarget ( S t r ing value ) {this . t a r g e t = value ;

}

public Big Intege r getEdgesId ( ) {120 return edgesId ;

}

public void setEdgesId ( B ig Intege r va lue ) {this . edges Id = value ;

}

public St r ing getXmiId ( ) {return xmiId ;

}130

public void setXmiId ( S t r ing value ) {this . xmiId = value ;

}

public St r ing getXmiType ( ) {return xmiType ;

}

public void setXmiType ( St r ing value ) {140 this . xmiType = value ;

}

}

D.11.7 Classe Element.java

package i t . jaxb . e co r ed i ag ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlRootElement ;

import javax . xml . bind . annotat ion . XmlSchemaType ;

10 import javax . xml . bind . annotat ion . XmlType ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” )

@XmlRootElement (name = ” element ” )

public class Element {

@XmlAttribute

571

Page 590: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@XmlSchemaType(name = ”anySimpleType” )

20 protected St r ing h r e f ;

@XmlAttribute (name = ” x s i n i l ” )

protected Boolean x s i N i l ;

@XmlAttribute (name = ” x s i n i l n i l ” )

protected Boolean x s i N i l n i l ;

@XmlAttribute (name = ” xmi type ” )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing xmiType ;

@XmlAttribute ( namespace = ” http ://www. w3 . org /2001/XMLSchema−INST” )

protected Boolean n i l ;

30public St r ing getHre f ( ) {

return h r e f ;

}

public void s e tHre f ( S t r ing value ) {this . h r e f = value ;

}

public Boolean i s X s i N i l ( ) {40 return x s i N i l ;

}

public void s e t X s i N i l ( Boolean value ) {this . x s i N i l = value ;

}

public Boolean i s X s i N i l n i l ( ) {return x s i N i l n i l ;

}50

public void s e t X s i N i l n i l ( Boolean value ) {this . x s i N i l n i l = value ;

}

public St r ing getXmiType ( ) {return xmiType ;

}

public void setXmiType ( St r ing value ) {60 this . xmiType = value ;

}

public Boolean i s N i l ( ) {return n i l ;

}

public void s e t N i l ( Boolean value ) {this . n i l = value ;

}70}

572

Page 591: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.11.8 Classe LayoutConstraint.java

package i t . jaxb . e co r ed i ag ;

import java . math . B ig In tege r ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlRootElement ;

10 import javax . xml . bind . annotat ion . XmlSchemaType ;

import javax . xml . bind . annotat ion . XmlType ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” )

@XmlRootElement (name = ” layoutConst ra in t ” )

public class LayoutConstraint {

@XmlAttribute

20 protected Big Intege r he ight ;

@XmlAttribute

protected Big Intege r width ;

@XmlAttribute ( r equ i r ed = true )

protected Big Intege r x ;

@XmlAttribute ( r equ i r ed = true )

protected Big Intege r y ;

@XmlAttribute (name = ” xmi id ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing xmiId ;

30 @XmlAttribute (name = ” xmi type ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing xmiType ;

public Big Intege r getHeight ( ) {return he ight ;

}

public void se tHe ight ( B ig Intege r va lue ) {this . he ight = value ;

40 }

public Big Intege r getWidth ( ) {return width ;

}

public void setWidth ( B ig Intege r va lue ) {this . width = value ;

}

50 public Big Intege r getX ( ) {return x ;

}

public void setX ( Big Intege r va lue ) {

573

Page 592: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

this . x = value ;

}

public Big Intege r getY ( ) {return y ;

60 }

public void setY ( Big Intege r va lue ) {this . y = value ;

}

public St r ing getXmiId ( ) {return xmiId ;

}

70 public void setXmiId ( S t r ing value ) {this . xmiId = value ;

}

public St r ing getXmiType ( ) {return xmiType ;

}

public void setXmiType ( St r ing value ) {this . xmiType = value ;

80 }

}

D.11.9 Classe ObjectFactory.java

package i t . jaxb . e co r ed i ag ;

import javax . xml . bind . annotat ion . XmlRegistry ;

@XmlRegistry

public class ObjectFactory {10

public ObjectFactory ( ) {}

public Bendpoints createBendpo ints ( ) {return new Bendpoints ( ) ;

}

public Edges createEdges ( ) {20 return new Edges ( ) ;

}

public TargetAnchor createTargetAnchor ( ) {

574

Page 593: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

return new TargetAnchor ( ) ;

}

public Diagram createDiagram ( ) {return new Diagram ( ) ;

}30

public Element createElement ( ) {return new Element ( ) ;

}

public LayoutConstraint createLayoutConstra int ( ) {return new LayoutConstraint ( ) ;

}

public S t y l e s c r e a t e S t y l e s ( ) {40 return new S t y l e s ( ) ;

}

public Chi ldren c r ea t eCh i ld r en ( ) {return new Chi ldren ( ) ;

}

public SourceAnchor createSourceAnchor ( ) {return new SourceAnchor ( ) ;

}50}

D.11.10 Classe SourceAnchor.java

package i t . jaxb . e co r ed i ag ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlRootElement ;

import javax . xml . bind . annotat ion . XmlSchemaType ;

10 import javax . xml . bind . annotat ion . XmlType ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” )

@XmlRootElement (name = ” sourceAnchor ” )

public class SourceAnchor {

@XmlAttribute (name = ” id ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

20 protected St r ing sourceAnchorId ;

@XmlAttribute (name = ” xmi id ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing xmiId ;

575

Page 594: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@XmlAttribute (name = ” xmi type ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing xmiType ;

public St r ing getSourceAnchorId ( ) {return sourceAnchorId ;

30 }

public void setSourceAnchorId ( S t r ing value ) {this . sourceAnchorId = value ;

}

public St r ing getXmiId ( ) {return xmiId ;

}

40 public void setXmiId ( S t r ing value ) {this . xmiId = value ;

}

public St r ing getXmiType ( ) {return xmiType ;

}

public void setXmiType ( St r ing value ) {this . xmiType = value ;

50 }

}

D.11.11 Classe Styles.java

package i t . jaxb . e co r ed i ag ;

import java . math . B ig In tege r ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlRootElement ;

10 import javax . xml . bind . annotat ion . XmlSchemaType ;

import javax . xml . bind . annotat ion . XmlType ;

import javax . xml . bind . annotat ion . adapters . Col lapsedStr ingAdapter ;

import javax . xml . bind . annotat ion . adapters . XmlJavaTypeAdapter ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” )

@XmlRootElement (name = ” s t y l e s ” )

public class S t y l e s {20

@XmlAttribute

protected Big Intege r f i l l C o l o r ;

576

Page 595: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

@XmlAttribute

protected Big Intege r fontCo lor ;

@XmlAttribute

protected Big Intege r fontHe ight ;

@XmlAttribute

protected Big Intege r l i n e C o l o r ;

@XmlAttribute

30 @XmlJavaTypeAdapter ( Col lapsedStr ingAdapter . class )

@XmlSchemaType(name = ”NCName” )

protected St r ing rout ing ;

@XmlAttribute (name = ” xmi id ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing xmiId ;

@XmlAttribute (name = ” xmi type ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing xmiType ;

40 public Big Intege r g e t F i l l C o l o r ( ) {return f i l l C o l o r ;

}

public void s e t F i l l C o l o r ( B ig Intege r va lue ) {this . f i l l C o l o r = value ;

}

public Big Intege r getFontColor ( ) {return f ontCo lor ;

50 }

public void setFontColor ( B ig Intege r va lue ) {this . f ontCo lor = value ;

}

public Big Intege r getFontHeight ( ) {return f ontHe ight ;

}

60 public void setFontHeight ( B ig Intege r value ) {this . f ontHe ight = value ;

}

public Big Intege r getL ineColor ( ) {return l i n e C o l o r ;

}

public void s e tL ineCo lo r ( B ig Intege r va lue ) {this . l i n e C o l o r = value ;

70 }

public St r ing getRouting ( ) {return rout ing ;

}

public void setRout ing ( S t r ing value ) {this . r out ing = value ;

}

577

Page 596: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

80 public St r ing getXmiId ( ) {return xmiId ;

}

public void setXmiId ( S t r ing value ) {this . xmiId = value ;

}

public St r ing getXmiType ( ) {return xmiType ;

90 }

public void setXmiType ( St r ing value ) {this . xmiType = value ;

}

}

D.11.12 Classe TargetAnchor.java

package i t . jaxb . e co r ed i ag ;

import javax . xml . bind . annotat ion . XmlAccessType ;

import javax . xml . bind . annotat ion . XmlAccessorType ;

import javax . xml . bind . annotat ion . XmlAttribute ;

import javax . xml . bind . annotat ion . XmlRootElement ;

import javax . xml . bind . annotat ion . XmlSchemaType ;

10 import javax . xml . bind . annotat ion . XmlType ;

@XmlAccessorType ( XmlAccessType . FIELD)

@XmlType(name = ”” )

@XmlRootElement (name = ” targetAnchor ” )

public class TargetAnchor {

@XmlAttribute (name = ” id ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

20 protected St r ing targetAnchorId ;

@XmlAttribute (name = ” xmi id ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing xmiId ;

@XmlAttribute (name = ” xmi type ” , r equ i r ed = true )

@XmlSchemaType(name = ”anySimpleType” )

protected St r ing xmiType ;

public St r ing getTargetAnchorId ( ) {return targetAnchorId ;

30 }

public void setTargetAnchorId ( S t r ing value ) {this . targetAnchorId = value ;

578

Page 597: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

}

public St r ing getXmiId ( ) {return xmiId ;

}

40 public void setXmiId ( S t r ing value ) {this . xmiId = value ;

}

public St r ing getXmiType ( ) {return xmiType ;

}

public void setXmiType ( St r ing value ) {this . xmiType = value ;

50 }

}

D.12 Package WebContent

D.12.1 File index.html

< !DOCTYPE html PUBLIC ’−//W3C//DTD XHTML 1.0 T r a n s i t i o n a l //EN’

’ http ://www. w3 . org /TR/xhtml1/DTD/xhtml1−t r a n s i t i o n a l . dtd ’>

<HTML xmlns=” http ://www. w3 . org /1999/ xhtml” xml : lang=”en” lang=”en”>

<HEAD>

<META http−equiv=”Content−Type” content=” text /html ; cha r s e t=UTF−8”>

<meta http−equiv=”REFRESH” content=” 0 ; u r l=/tesiWebApp/ a p p l i c a t i o n /”>

<HEAD>

</HEAD>

<BODY>

10 </BODY>

</HTML>

D.13 Package WebContent.META-INF

D.13.1 File orm.xml

<?xml version=” 1 .0 ” encoding=”UTF−8”?>

<ent i ty−mappings version=” 1 .0 ”

xmlns=” h t t p : // java . sun . com/xml/ns/ p e r s i s t e n c e /orm”

xmlns :x s i=” h t t p : //www. w3 . org /2001/XMLSchema−i n s t ance ”

xs i : s chemaLocat ion=” h t t p : // java . sun . com/xml/ns/ p e r s i s t e n c e /orm

h t t p : // java . sun . com/xml/ns/ p e r s i s t e n c e / orm 1 0 . xsd”>

</ ent i ty−mappings>

579

Page 598: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

D.13.2 File persistence.xml

<?xml version=” 1 .0 ” encoding=”UTF−8”?>

<p e r s i s t e n c e version=” 1 .0 ”

xmlns=” h t t p : // java . sun . com/xml/ns/ p e r s i s t e n c e ”

xmlns :x s i=” h t t p : //www. w3 . org /2001/XMLSchema−i n s t ance ”

xs i : s chemaLocat ion=” h t t p : // java . sun . com/xml/ns/ p e r s i s t e n c e

h t t p : // java . sun . com/xml/ns/ p e r s i s t e n c e / p e r s i s t e n c e 1 0 . xsd”>

<p e r s i s t e n c e−uni t name=”tesiWebApp” t ransac t i on−type=”RESOURCE LOCAL”>

<d e s c r i p t i o n>org . apache . openjpa . p e r s i s t e n c e . Per s i s t enceProv ide r Imp l</ d e s c r i p t i o n>

<prov ide r>org . e c l i p s e . p e r s i s t e n c e . jpa . P e r s i s t en c e Pr ov id e r</ prov ide r>

<c l a s s> i t . uniroma2 . norge . model . jpa . User</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . Ru l eMul t ep l i c i ty</ c l a s s>

10 <c l a s s> i t . uniroma2 . norge . model . jpa . RuleExclus ion</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . Role</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . Quest ionna i re</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . Question</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . Pro j e c t</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . Organizat ion</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . Mpackage</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . Model</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . M l i t e r a l</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . Mf ie ld</ c l a s s>

20 <c l a s s> i t . uniroma2 . norge . model . jpa . Mclass</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . DocumentHistory</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . Document</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . DiagEdge</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . DiagChi ldren</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e H i s t o r y</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . De l i v e rab l eEv idenceHi s to ry</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . De l ive rab l eEv idence</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . D e l i v e r a b l e</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . Del ivSubcateg</ c l a s s>

30 <c l a s s> i t . uniroma2 . norge . model . jpa . Del ivCateg</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . D e f a u l t D e l i v e r a b l e</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . Assignment</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . AnswsetHistory</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . AnswsetAnswDel iverableHistory</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . AnswsetAnsw</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . AnswerSet</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . Alternat iveAnswer</ c l a s s>

<c l a s s> i t . uniroma2 . norge . model . jpa . Re lat ion</ c l a s s>

<p r o p e r t i e s>

40 <property name=” e c l i p s e l i n k . jdbc . u r l ”

va lue=” jdbc :mysq l : // l o c a l h o s t : 3 3 0 6 / norge ” />

<property name=” e c l i p s e l i n k . jdbc . d r i v e r ” value=”com . mysql . jdbc . Dr iver ” />

<property name=” e c l i p s e l i n k . jdbc . user ” value=” root ” />

<property name=” e c l i p s e l i n k . jdbc . password” value=”−−−−−−−−−−−−” />

<property name=” e c l i p s e l i n k . l ogg ing . timestamp” value=” true ” />

<property name=” e c l i p s e l i n k . l ogg ing . except i ons ” value=” true ” />

<property name=” e c l i p s e l i n k . l ogg ing . l e v e l ” value=”SEVERE” />

<property name=” e c l i p s e l i n k . query−r e s u l t s−cache ” value=” f a l s e ”/>

<property name=” e c l i p s e l i n k . cache . shared . d e f a u l t ” va lue=” f a l s e ”/>

<property name=” e c l i p s e l i n k . cache . s i z e . d e f a u l t ” va lue=”0”/>

50 <property name=” e c l i p s e l i n k . cache . type . d e f a u l t ” va lue=”None”/>

<property name=” e c l i p s e l i n k . f l u sh−c l e a r . cache ” value=”Merge” />

580

Page 599: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

<property name=” e c l i p s e l i n k . cache . type . d e f a u l t ” va lue=”Weak” />

<property name=” e c l i p s e l i n k . ddl−gene ra t i on ” value=” create−t a b l e s ” />

<property name=” e c l i p s e l i n k . ddl−gene ra t i on . output−mode” value=” sq l−s c r i p t ” />

<property name=” e c l i p s e l i n k . l ogg ing . l o g g e r ” value=” DefaultLogger ” />

</ p r o p e r t i e s>

</ p e r s i s t e n c e−uni t>

</ p e r s i s t e n c e>

D.14 Package WebContent.WEB-INF

D.14.1 File web.xml

<?xml version=” 1 .0 ” encoding=”UTF−8”?>

<web−app xmlns :x s i=” ht tp : //www. w3 . org /2001/XMLSchema−i n s t ance ”

xmlns=” h t t p : // java . sun . com/xml/ns/ javaee ”

xmlns:web=” ht tp : // java . sun . com/xml/ns/ javaee /web−app 2 5 . xsd”

xs i : s chemaLocat ion=” h t t p : // java . sun . com/xml/ns/ javaee

h t t p : // java . sun . com/xml/ns/ javaee /web−app 2 5 . xsd”

id=”WebApp ID” version=” 2 .5 ”>

<di sp lay−name>tesiWebApp</ d i sp lay−name>

<context−param>

<d e s c r i p t i o n>Vaadin production mode</ d e s c r i p t i o n>

<param−name>productionMode</param−name>

10 <param−value>t rue</param−value>

</ context−param>

<s e cu r i t y−c o n s t r a i n t>

<di sp lay−name>SecureChannelConstra int</ d i sp lay−name>

<web−re source−c o l l e c t i o n>

<web−re source−name>Web a p p l i c a t i o n</web−re source−name>

<d e s c r i p t i o n />

<ur l−pattern>/ a p p l i c a t i o n /∗</ ur l−pattern>

</web−re source−c o l l e c t i o n>

<user−data−c o n s t r a i n t>

20 <d e s c r i p t i o n>Require encrypted channel</ d e s c r i p t i o n>

<t ransport−guarantee>CONFIDENTIAL</ transport−guarantee>

</ user−data−c o n s t r a i n t>

</ s e cu r i t y−c o n s t r a i n t>

<s e r v l e t>

<s e r v l e t−name>EvidenceAgreement App l i ca t ion</ s e r v l e t−name>

<s e r v l e t−c l a s s>com . vaadin . t e rmina l . gwt . s e r v e r . A p p l i c a t i o n S e r v l e t</ s e r v l e t−c l a s s>

< i n i t−param>

<d e s c r i p t i o n>

Vaadin a p p l i c a t i o n c l a s s to s t a r t</ d e s c r i p t i o n>

30 <param−name>a p p l i c a t i o n</param−name>

<param−value> i t . uniroma2 . norge . web . Tes iwebAppl icat ion</param−value>

</ i n i t−param>

< i n i t−param>

<d e s c r i p t i o n> Appl i ca t ion widget s e t</ d e s c r i p t i o n>

<param−name>widget s e t</param−name>

<param−value> i t . uniroma2 . norge . web . w idge t se t . TesiwebappWidgetset</param−value>

</ i n i t−param>

</ s e r v l e t>

581

Page 600: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

APPENDICE D. CODICE SORGENTE DI EVIDENCEAGREEMENT

<s e r v l e t−mapping>

40 <s e r v l e t−name>EvidenceAgreement App l i ca t ion</ s e r v l e t−name>

<ur l−pattern>/ a p p l i c a t i o n /∗</ ur l−pattern>

</ s e r v l e t−mapping>

<s e r v l e t−mapping>

<s e r v l e t−name>EvidenceAgreement App l i ca t ion</ s e r v l e t−name>

<ur l−pattern>/VAADIN/∗</ ur l−pattern>

</ s e r v l e t−mapping>

<welcome− f i l e − l i s t>

<welcome− f i l e>index . html</welcome− f i l e>

<welcome− f i l e>index . htm</welcome− f i l e>

50 <welcome− f i l e>index . j sp</welcome− f i l e>

<welcome− f i l e>d e f a u l t . html</welcome− f i l e>

<welcome− f i l e>d e f a u l t . htm</welcome− f i l e>

<welcome− f i l e>d e f a u l t . j sp</welcome− f i l e>

</welcome− f i l e − l i s t>

</web−app>

582

Page 601: Universita di Roma ‘Tor Vergata’ Universita di Roma ‘Tor Vergata’ FACOLTA DI INGEGNERIA Corso di Laurea Specialistica in Ingegneria Informatica Tesi sperimentale Precondizioni

‘Tutto l’universo cospira affinche

chi lo desidera con tutto se

stesso possa riuscire a realizzare

i propri sogni.

Paulo Coelho, L’Alchimista

‘Il computer non e una

macchina intelligente che aiuta

le persone stupide, anzi e una

macchina stupida che funziona

solo nelle mani delle persone

intelligenti.’

Umberto Eco, Come scrivere

una tesi di laurea con il personal

computer, 1986