Rev 1505 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1505 | jmachado | 1 | package pt.estgp.estgweb.services.courses; |
2 | |||
3 | import jomm.dao.impl.AbstractDao; |
||
4 | import pt.estgp.estgweb.domain.CourseDepartment; |
||
5 | import pt.estgp.estgweb.domain.DomainObjectFactory; |
||
6 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
||
7 | import pt.estgp.estgweb.domain.dao.impl.CourseDepartmentDaoImpl; |
||
8 | import pt.estgp.estgweb.utils.ConfigProperties; |
||
9 | |||
10 | /** |
||
11 | * Created by jorgemachado on 15/09/16. |
||
12 | * |
||
13 | * to be called from ANT tasks |
||
14 | * |
||
15 | * |
||
16 | * UPDATE DO MYSQL PARA OS DEPARTAMENTOS |
||
17 | * |
||
18 | * 1 - FAZER O UPDATE HIBERNATE SQL - Ira criar a tabela de departamentos |
||
19 | * As chaves estrangeiras não poderão ser criadas porque existem falhas de linkagem |
||
20 | * 2 - Correr esta tarefa - Irá criar os departamentos ant -f inportRoutines.xml updateCourseDepartments |
||
21 | * 3 - Correr novamente o update hibernate sql e a chave será atualizada |
||
22 | */ |
||
23 | public class UpdateDepartmentsTask |
||
24 | { |
||
25 | public static void main(1.5.0/docs/api/java/lang/String.html">String [] args) |
||
26 | { |
||
27 | |||
28 | AbstractDao.getCurrentSession().beginTransaction(); |
||
29 | |||
30 | |||
31 | new UpdateDepartmentsTask().updateDepartmentsDefault(); |
||
32 | |||
33 | AbstractDao.getCurrentSession().getTransaction().commit(); |
||
34 | |||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Check default departments if they already exist in database |
||
39 | * ESECS |
||
40 | * a) Comunicação, Artes e Tecnologias; CAT |
||
41 | * b) Educação e Formação; EF |
||
42 | * c) Intervenção e Desenvolvimento Social. IDS |
||
43 | * |
||
44 | * ESTG |
||
45 | * a) Tecnologias e Design TD |
||
46 | * b) Ciências Empresariais, Sociais e Humanas”. CESH |
||
47 | * |
||
48 | * ESAE |
||
49 | * a) Agricultura e Recursos Naturais ARN |
||
50 | * b) Ciência e Tecnologia Animal CTA |
||
51 | * |
||
52 | * ESSP |
||
53 | * |
||
54 | * a) Ciências e Tecnologias da Saúde |
||
55 | * |
||
56 | * Properties |
||
57 | * institution.code.prefix.inverse.ESTG=1 |
||
58 | institution.code.prefix.inverse.ESAE=2 |
||
59 | institution.code.prefix.inverse.ESECS=3 |
||
60 | institution.code.prefix.inverse.ESS=4 |
||
61 | |||
62 | */ |
||
63 | public void updateDepartmentsDefault() |
||
64 | { |
||
65 | |||
66 | CourseDepartmentDaoImpl dao = DaoFactory.getCourseDepartmentDaoImpl(); |
||
67 | |||
68 | /* |
||
69 | * ESECS |
||
70 | * */ |
||
71 | 1.5.0/docs/api/java/lang/String.html">String sigla = "cat"; |
||
72 | 1.5.0/docs/api/java/lang/String.html">String nome = "Comunicação, Artes e Tecnologias"; |
||
73 | 1.5.0/docs/api/java/lang/String.html">String nomeEn = "Comunication Arts and Technology"; |
||
74 | 1.5.0/docs/api/java/lang/String.html">String nomeEs = "Comunicación, Artes y Tecnologías"; |
||
75 | 1.5.0/docs/api/java/lang/String.html">String nomeFr = "Communication, Arts et Technologies"; |
||
76 | 1.5.0/docs/api/java/lang/String.html">String institutionalCode = ConfigProperties.getProperty("institution.code.prefix.inverse.ESECS"); |
||
77 | |||
78 | createDepartment(dao, sigla, nome, nomeEn, nomeEs, nomeFr, institutionalCode); |
||
79 | |||
80 | sigla = "ef"; |
||
81 | nome = "Educação e Formação"; |
||
82 | nomeEn = "Education and training"; |
||
83 | nomeEs = "Educación y formación"; |
||
84 | nomeFr = "Éducation et formation"; |
||
85 | institutionalCode = ConfigProperties.getProperty("institution.code.prefix.inverse.ESECS"); |
||
86 | |||
87 | createDepartment(dao, sigla, nome, nomeEn, nomeEs, nomeFr, institutionalCode); |
||
88 | |||
89 | sigla = "ids"; |
||
90 | nome = "Intervenção e Desenvolvimento Social"; |
||
91 | nomeEn = "Intervention and Social Development"; |
||
92 | nomeEs = "Intervención y Desarrollo Social"; |
||
93 | nomeFr = "Intervention et du Développement social"; |
||
94 | institutionalCode = ConfigProperties.getProperty("institution.code.prefix.inverse.ESECS"); |
||
95 | |||
96 | createDepartment(dao, sigla, nome, nomeEn, nomeEs, nomeFr, institutionalCode); |
||
97 | |||
98 | |||
99 | /** |
||
100 | * ESTG |
||
101 | */ |
||
102 | sigla = "td"; |
||
103 | nome = "Tecnologias e Design"; |
||
104 | nomeEn = "Technology and Design"; |
||
105 | nomeEs = "Tecnología y Diseño"; |
||
106 | nomeFr = "Technologie et Design"; |
||
107 | institutionalCode = ConfigProperties.getProperty("institution.code.prefix.inverse.ESTG"); |
||
108 | |||
109 | createDepartment(dao, sigla, nome, nomeEn, nomeEs, nomeFr, institutionalCode); |
||
110 | |||
111 | sigla = "cesh"; |
||
112 | nome = "Ciências Empresariais, Sociais e Humanas"; |
||
113 | nomeEn = "Business Sciences, Social and Human"; |
||
114 | nomeEs = "Ciencias empresariales, Social y Humano"; |
||
115 | nomeFr = "Entreprise Sciences, Sciences sociales et humaines"; |
||
116 | institutionalCode = ConfigProperties.getProperty("institution.code.prefix.inverse.ESTG"); |
||
117 | |||
118 | createDepartment(dao, sigla, nome, nomeEn, nomeEs, nomeFr, institutionalCode); |
||
119 | |||
120 | |||
121 | /** |
||
122 | * ESAE |
||
123 | */ |
||
124 | sigla = "arn"; |
||
125 | nome = "Agricultura e Recursos Naturais"; |
||
126 | nomeEn = "Agriculture and Natural Resources"; |
||
127 | nomeEs = "Agricultura y Recursos Naturales"; |
||
128 | nomeFr = "Agriculture et ressources naturelles"; |
||
129 | institutionalCode = ConfigProperties.getProperty("institution.code.prefix.inverse.ESAE"); |
||
130 | |||
131 | createDepartment(dao, sigla, nome, nomeEn, nomeEs, nomeFr, institutionalCode); |
||
132 | |||
133 | sigla = "cta"; |
||
134 | nome = "Ciência e Tecnologia Animal"; |
||
135 | nomeEn = "Animal Science and Technology"; |
||
136 | nomeEs = "Ciencia y Tecnología Animal"; |
||
137 | nomeFr = "Animal Science et technologie"; |
||
138 | institutionalCode = ConfigProperties.getProperty("institution.code.prefix.inverse.ESAE"); |
||
139 | |||
140 | createDepartment(dao, sigla, nome, nomeEn, nomeEs, nomeFr, institutionalCode); |
||
141 | |||
142 | |||
143 | /** |
||
144 | * ESSP |
||
145 | */ |
||
146 | sigla = "cts"; |
||
147 | nome = "Ciências e Tecnologias da Saúde"; |
||
148 | nomeEn = "Science and Health Technologies"; |
||
149 | nomeEs = "Ciencia y Salud Tecnologías"; |
||
150 | nomeFr = "Sciences et technologies de la santé"; |
||
151 | institutionalCode = ConfigProperties.getProperty("institution.code.prefix.inverse.ESS"); |
||
152 | |||
153 | createDepartment(dao, sigla, nome, nomeEn, nomeEs, nomeFr, institutionalCode); |
||
154 | } |
||
155 | |||
156 | private void createDepartment(CourseDepartmentDaoImpl dao, 1.5.0/docs/api/java/lang/String.html">String sigla, 1.5.0/docs/api/java/lang/String.html">String nome, 1.5.0/docs/api/java/lang/String.html">String nomeEn, 1.5.0/docs/api/java/lang/String.html">String nomeEs, 1.5.0/docs/api/java/lang/String.html">String nomeFr, 1.5.0/docs/api/java/lang/String.html">String institutionalCode) { |
||
157 | CourseDepartment courseDepartment = dao.findBySigla(sigla); |
||
158 | if(courseDepartment == null) |
||
159 | { |
||
160 | courseDepartment = DomainObjectFactory.createCourseDepartmentImpl(); |
||
161 | courseDepartment.setSigla(sigla); |
||
162 | courseDepartment.setInstitutionalCode(institutionalCode); |
||
163 | courseDepartment.setName(nome); |
||
164 | courseDepartment.setNameEn(nomeEn); |
||
165 | courseDepartment.setNameEs(nomeEs); |
||
166 | courseDepartment.setNameFr(nomeFr); |
||
1507 | jmachado | 167 | courseDepartment.setActive(true); |
1505 | jmachado | 168 | dao.save(courseDepartment); |
169 | } |
||
170 | } |
||
171 | } |