Rev 1887 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1887 | Rev 1927 | ||
---|---|---|---|
1 | package pt.estgp.estgweb.services.courses; |
1 | package pt.estgp.estgweb.services.courses; |
2 | 2 | ||
3 | import com.owlike.genson.Genson; |
3 | import com.owlike.genson.Genson; |
4 | import com.owlike.genson.GensonBuilder; |
4 | import com.owlike.genson.GensonBuilder; |
5 | import com.owlike.genson.reflect.VisibilityFilter; |
5 | import com.owlike.genson.reflect.VisibilityFilter; |
6 | import jomm.dao.impl.AbstractDao; |
6 | import jomm.dao.impl.AbstractDao; |
7 | import jomm.utils.BytesUtils; |
7 | import jomm.utils.BytesUtils; |
8 | import jomm.utils.FilesUtils; |
8 | import jomm.utils.FilesUtils; |
9 | import jomm.utils.StreamsUtils; |
9 | import jomm.utils.StreamsUtils; |
10 | import org.apache.log4j.Logger; |
10 | import org.apache.log4j.Logger; |
11 | import org.dom4j.Document; |
11 | import org.dom4j.Document; |
12 | import org.hibernate.Query; |
12 | import org.hibernate.Query; |
13 | import org.json.JSONArray; |
13 | import org.json.JSONArray; |
14 | import org.json.JSONException; |
14 | import org.json.JSONException; |
15 | import org.json.JSONObject; |
15 | import org.json.JSONObject; |
16 | import pt.estgp.estgweb.domain.*; |
16 | import pt.estgp.estgweb.domain.*; |
17 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
17 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
18 | import pt.estgp.estgweb.domain.views.CourseView; |
18 | import pt.estgp.estgweb.domain.views.CourseView; |
19 | import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum; |
19 | import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum; |
20 | import pt.estgp.estgweb.filters.exceptions.AccessDeniedException; |
20 | import pt.estgp.estgweb.filters.exceptions.AccessDeniedException; |
21 | import pt.estgp.estgweb.services.courses.xsd.*; |
21 | import pt.estgp.estgweb.services.courses.xsd.*; |
22 | import pt.estgp.estgweb.services.data.IRepositoryFile; |
22 | import pt.estgp.estgweb.services.data.IRepositoryFile; |
23 | import pt.estgp.estgweb.services.data.RepositoryService; |
23 | import pt.estgp.estgweb.services.data.RepositoryService; |
24 | import pt.estgp.estgweb.services.expceptions.AlreadyExistsException; |
24 | import pt.estgp.estgweb.services.expceptions.AlreadyExistsException; |
25 | import pt.estgp.estgweb.services.expceptions.ServiceException; |
25 | import pt.estgp.estgweb.services.expceptions.ServiceException; |
26 | import pt.estgp.estgweb.services.users.ReplaceRoleResult; |
26 | import pt.estgp.estgweb.services.users.ReplaceRoleResult; |
27 | import pt.estgp.estgweb.services.users.UserRoleConfigService; |
27 | import pt.estgp.estgweb.services.users.UserRoleConfigService; |
28 | import pt.estgp.estgweb.utils.ConfigProperties; |
28 | import pt.estgp.estgweb.utils.ConfigProperties; |
29 | import pt.estgp.estgweb.utils.Dom4jUtil; |
29 | import pt.estgp.estgweb.utils.Dom4jUtil; |
30 | import pt.estgp.estgweb.utils.Globals; |
30 | import pt.estgp.estgweb.utils.Globals; |
31 | import pt.estgp.estgweb.utils.StringsUtils; |
31 | import pt.estgp.estgweb.utils.StringsUtils; |
32 | import pt.utl.ist.berserk.logic.serviceManager.IService; |
32 | import pt.utl.ist.berserk.logic.serviceManager.IService; |
33 | 33 | ||
34 | import javax.xml.bind.JAXBContext; |
34 | import javax.xml.bind.JAXBContext; |
35 | import javax.xml.bind.JAXBException; |
35 | import javax.xml.bind.JAXBException; |
36 | import javax.xml.bind.Marshaller; |
36 | import javax.xml.bind.Marshaller; |
37 | import javax.xml.bind.Unmarshaller; |
37 | import javax.xml.bind.Unmarshaller; |
38 | import java.io.*; |
38 | import java.io.*; |
39 | import java.net.URL; |
39 | import java.net.URL; |
40 | import java.util.*; |
40 | import java.util.*; |
41 | 41 | ||
42 | /* |
42 | /* |
43 | * @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt |
43 | * @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt |
44 | * |
44 | * |
45 | * |
45 | * |
46 | * Created at 17/Out/2003 , 23:45:24 |
46 | * Created at 17/Out/2003 , 23:45:24 |
47 | * |
47 | * |
48 | */ |
48 | */ |
49 | /** |
49 | /** |
50 | * @author Jorge Machado |
50 | * @author Jorge Machado |
51 | * |
51 | * |
52 | * |
52 | * |
53 | * Created at 17/Out/2003 , 23:45:24 |
53 | * Created at 17/Out/2003 , 23:45:24 |
54 | * |
54 | * |
55 | */ |
55 | */ |
56 | public class CoursesService implements IService |
56 | public class CoursesService implements IService |
57 | { |
57 | { |
58 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(CoursesService.class); |
58 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(CoursesService.class); |
59 | 59 | ||
60 | RepositoryService repositoryService = new RepositoryService(); |
60 | RepositoryService repositoryService = new RepositoryService(); |
61 | 61 | ||
62 | 62 | ||
63 | 63 | ||
64 | /** |
64 | /** |
65 | * Servico e subservico para termos acesso as variaveis de controlo |
65 | * Servico e subservico para termos acesso as variaveis de controlo |
66 | * @param id |
66 | * @param id |
67 | * @param initUnits |
67 | * @param initUnits |
68 | * @return |
68 | * @return |
69 | * @throws ServiceException |
69 | * @throws ServiceException |
70 | */ |
70 | */ |
71 | public CourseView loadCourse(long id, boolean initUnits) |
71 | public CourseView loadCourse(long id, boolean initUnits) |
72 | throws ServiceException |
72 | throws ServiceException |
73 | { |
73 | { |
74 | return loadCourse(id,initUnits,false); |
74 | return loadCourse(id,initUnits,false); |
75 | } |
75 | } |
76 | public CourseView loadCourseAndStudiesPlans(long id, boolean initUnits) |
76 | public CourseView loadCourseAndStudiesPlans(long id, boolean initUnits) |
77 | throws ServiceException |
77 | throws ServiceException |
78 | { |
78 | { |
79 | return loadCourse(id,initUnits,true); |
79 | return loadCourse(id,initUnits,true); |
80 | } |
80 | } |
81 | 81 | ||
82 | 82 | ||
83 | private CourseView loadCourse(long id, boolean initUnits,boolean loadStudiesPlans) throws ServiceException |
83 | private CourseView loadCourse(long id, boolean initUnits,boolean loadStudiesPlans) throws ServiceException |
84 | { |
84 | { |
85 | Course c = DaoFactory.getCourseDaoImpl().get(id); |
85 | Course c = DaoFactory.getCourseDaoImpl().get(id); |
86 | 86 | ||
87 | if(c != null) |
87 | if(c != null) |
88 | { |
88 | { |
89 | return getCourseView(initUnits, c,loadStudiesPlans); |
89 | return getCourseView(initUnits, c,loadStudiesPlans); |
90 | } |
90 | } |
91 | return null; |
91 | return null; |
92 | } |
92 | } |
93 | 93 | ||
94 | /** |
94 | /** |
95 | * Servico e subservico para termos acesso as variaveis de controlo |
95 | * Servico e subservico para termos acesso as variaveis de controlo |
96 | * @param code |
96 | * @param code |
97 | * @param initUnits |
97 | * @param initUnits |
98 | * @return |
98 | * @return |
99 | * @throws ServiceException |
99 | * @throws ServiceException |
100 | */ |
100 | */ |
101 | 101 | ||
102 | public CourseView loadCourseByCode(1.5.0/docs/api/java/lang/String.html">String code, boolean initUnits) throws ServiceException |
102 | public CourseView loadCourseByCode(1.5.0/docs/api/java/lang/String.html">String code, boolean initUnits) throws ServiceException |
103 | { |
103 | { |
104 | return loadCourseByCode(code,initUnits,false); |
104 | return loadCourseByCode(code,initUnits,false); |
105 | } |
105 | } |
106 | public CourseView loadCourseByCodeAndStudiesPlans(1.5.0/docs/api/java/lang/String.html">String code, boolean initUnits) throws ServiceException |
106 | public CourseView loadCourseByCodeAndStudiesPlans(1.5.0/docs/api/java/lang/String.html">String code, boolean initUnits) throws ServiceException |
107 | { |
107 | { |
108 | return loadCourseByCode(code,initUnits,true); |
108 | return loadCourseByCode(code,initUnits,true); |
109 | } |
109 | } |
110 | 110 | ||
111 | 111 | ||
112 | private CourseView loadCourseByCode(1.5.0/docs/api/java/lang/String.html">String code, boolean initUnits,boolean loadStudiesPlans) throws ServiceException |
112 | private CourseView loadCourseByCode(1.5.0/docs/api/java/lang/String.html">String code, boolean initUnits,boolean loadStudiesPlans) throws ServiceException |
113 | { |
113 | { |
114 | try{ |
114 | try{ |
115 | Course c = DaoFactory.getCourseDaoImpl().findCourseByCode(code); |
115 | Course c = DaoFactory.getCourseDaoImpl().findCourseByCode(code); |
116 | if(c != null) |
116 | if(c != null) |
117 | { |
117 | { |
118 | return getCourseView(initUnits, c, loadStudiesPlans); |
118 | return getCourseView(initUnits, c, loadStudiesPlans); |
119 | } |
119 | } |
120 | } |
120 | } |
121 | catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
121 | catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
122 | { |
122 | { |
123 | logger.error(e + " loading code:" + code,e); |
123 | logger.error(e + " loading code:" + code,e); |
124 | throw new ServiceException("loading code: " + code + " - " + e.toString(),e); |
124 | throw new ServiceException("loading code: " + code + " - " + e.toString(),e); |
125 | } |
125 | } |
126 | return null; |
126 | return null; |
127 | } |
127 | } |
128 | 128 | ||
129 | /** |
129 | /** |
130 | * Carrega efetivamente o curso nos servicos load e load by code |
130 | * Carrega efetivamente o curso nos servicos load e load by code |
131 | * @param initUnits |
131 | * @param initUnits |
132 | * @param c |
132 | * @param c |
133 | * @return |
133 | * @return |
134 | */ |
134 | */ |
135 | 135 | ||
136 | private CourseView getCourseView(boolean initUnits, Course c,boolean loadStudiesPlans) { |
136 | private CourseView getCourseView(boolean initUnits, Course c,boolean loadStudiesPlans) { |
137 | CourseView cV = new CourseView(c,initUnits); |
137 | CourseView cV = new CourseView(c,initUnits); |
138 | /* |
138 | /* |
139 | * todo Parte antig antigo XML do plano de estudos para remover futuramente*/ |
139 | * todo Parte antig antigo XML do plano de estudos para remover futuramente*/ |
140 | if(c.getStudiesPlan() != null) |
140 | if(c.getStudiesPlan() != null) |
141 | { |
141 | { |
142 | RepositoryFileImpl repositoryFile = repositoryService.loadView(c.getStudiesPlan()); |
142 | RepositoryFileImpl repositoryFile = repositoryService.loadView(c.getStudiesPlan()); |
143 | cV.setStudiesPlan(repositoryFile); |
143 | cV.setStudiesPlan(repositoryFile); |
144 | } |
144 | } |
145 | if(loadStudiesPlans && c.getStudiesPlans() != null && c.getStudiesPlans().size() > 0) |
145 | if(loadStudiesPlans && c.getStudiesPlans() != null && c.getStudiesPlans().size() > 0) |
146 | { |
146 | { |
147 | for(CourseStudiesPlan sp : c.getStudiesPlans()) |
147 | for(CourseStudiesPlan sp : c.getStudiesPlans()) |
148 | { |
148 | { |
149 | sp.getVersion(); |
149 | sp.getVersion(); |
150 | cV.getCourseStudiesPlans().add(sp); |
150 | cV.getCourseStudiesPlans().add(sp); |
151 | } |
151 | } |
152 | } |
152 | } |
153 | 153 | ||
154 | return cV; |
154 | return cV; |
155 | } |
155 | } |
156 | 156 | ||
157 | public List<String> loadImportYears(UserSession userSession) throws ServiceException |
157 | public List<String> loadImportYears(UserSession userSession) throws ServiceException |
158 | { |
158 | { |
159 | List<String> importYears = DaoFactory.getCourseDaoImpl().loadImportYears(); |
159 | List<String> importYears = DaoFactory.getCourseDaoImpl().loadImportYears(); |
160 | List<String> imStrings = new ArrayList<String>(); |
160 | List<String> imStrings = new ArrayList<String>(); |
161 | for(1.5.0/docs/api/java/lang/String.html">String importYear: importYears) |
161 | for(1.5.0/docs/api/java/lang/String.html">String importYear: importYears) |
162 | { |
162 | { |
163 | imStrings.add(importYear); |
163 | imStrings.add(importYear); |
164 | } |
164 | } |
165 | return imStrings; |
165 | return imStrings; |
166 | } |
166 | } |
167 | 167 | ||
168 | 168 | ||
169 | 169 | ||
170 | public CourseView submitCourse(CourseView courseView, |
170 | public CourseView submitCourse(CourseView courseView, |
171 | 5+0%2Fdocs%2Fapi+InputStream">InputStream stream, |
171 | 5+0%2Fdocs%2Fapi+InputStream">InputStream stream, |
172 | 1.5.0/docs/api/java/lang/String.html">String name, |
172 | 1.5.0/docs/api/java/lang/String.html">String name, |
173 | int size, |
173 | int size, |
174 | 1.5.0/docs/api/java/lang/String.html">String contentType, |
174 | 1.5.0/docs/api/java/lang/String.html">String contentType, |
175 | UserSession userSession) throws ServiceException, JAXBException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
175 | UserSession userSession) throws ServiceException, JAXBException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
176 | Course c; |
176 | Course c; |
177 | if(courseView.getId() > 0) |
177 | if(courseView.getId() > 0) |
178 | { |
178 | { |
179 | c = DaoFactory.getCourseDaoImpl().get(courseView.getId()); |
179 | c = DaoFactory.getCourseDaoImpl().get(courseView.getId()); |
180 | } |
180 | } |
181 | else |
181 | else |
182 | { |
182 | { |
183 | c = DaoFactory.getCourseDaoImpl().findCourseByCodeAndYear(courseView.getCode(),courseView.getImportYear()); |
183 | c = DaoFactory.getCourseDaoImpl().findCourseByCodeAndYear(courseView.getCode(),courseView.getImportYear()); |
184 | if(c != null) |
184 | if(c != null) |
185 | throw new AlreadyExistsException(AlreadyExistsException.ALREADY_EXISTS_COURSE); |
185 | throw new AlreadyExistsException(AlreadyExistsException.ALREADY_EXISTS_COURSE); |
186 | c = DomainObjectFactory.createCourseImpl(); |
186 | c = DomainObjectFactory.createCourseImpl(); |
187 | DaoFactory.getCourseDaoImpl().save(c); |
187 | DaoFactory.getCourseDaoImpl().save(c); |
188 | } |
188 | } |
189 | 189 | ||
190 | 1.5.0/docs/api/java/lang/String.html">String htmlTrasformationResult = null; |
190 | 1.5.0/docs/api/java/lang/String.html">String htmlTrasformationResult = null; |
191 | 191 | ||
192 | //Stream que pode vir do upload da UIde Admin de Cursos |
192 | //Stream que pode vir do upload da UIde Admin de Cursos |
193 | htmlTrasformationResult = uploadStudiesPlan(stream, name, size, contentType, userSession, c,false,null); |
193 | htmlTrasformationResult = uploadStudiesPlan(stream, name, size, contentType, userSession, c,false,null); |
194 | courseView.persistViewInObject(c); |
194 | courseView.persistViewInObject(c); |
195 | CourseView cv = loadCourse(c.getId(),false); |
195 | CourseView cv = loadCourse(c.getId(),false); |
196 | cv.setHtmlResult(htmlTrasformationResult); |
196 | cv.setHtmlResult(htmlTrasformationResult); |
197 | 197 | ||
198 | /** |
198 | /** |
199 | * New## generating course json |
199 | * New## generating course json |
200 | */ |
200 | */ |
201 | generateCourseJson(c); |
201 | generateCourseJson(c); |
202 | 202 | ||
203 | return cv; |
203 | return cv; |
204 | } |
204 | } |
205 | 205 | ||
206 | private 1.5.0/docs/api/java/lang/String.html">String uploadStudiesPlan(5+0%2Fdocs%2Fapi+InputStream">InputStream stream, 1.5.0/docs/api/java/lang/String.html">String name, int size, 1.5.0/docs/api/java/lang/String.html">String contentType, UserSession userSession, Course c,boolean forceUrlFichas, 1.5.0/docs/api/java/lang/String.html">String systemUrl) throws JAXBException { |
206 | private 1.5.0/docs/api/java/lang/String.html">String uploadStudiesPlan(5+0%2Fdocs%2Fapi+InputStream">InputStream stream, 1.5.0/docs/api/java/lang/String.html">String name, int size, 1.5.0/docs/api/java/lang/String.html">String contentType, UserSession userSession, Course c,boolean forceUrlFichas, 1.5.0/docs/api/java/lang/String.html">String systemUrl) throws JAXBException { |
207 | 1.5.0/docs/api/java/lang/String.html">String htmlTrasformationResult = null; |
207 | 1.5.0/docs/api/java/lang/String.html">String htmlTrasformationResult = null; |
208 | //APENAS NO CASO DO AMDIN FAZER UPLOAD DE UM XML |
208 | //APENAS NO CASO DO AMDIN FAZER UPLOAD DE UM XML |
209 | if(stream != null && size > 0) |
209 | if(stream != null && size > 0) |
210 | { |
210 | { |
211 | 1.5.0/docs/api/java/lang/String.html">String extension = FilesUtils.getExtension(name); |
211 | 1.5.0/docs/api/java/lang/String.html">String extension = FilesUtils.getExtension(name); |
212 | if(c.getStudiesPlan() == null) |
212 | if(c.getStudiesPlan() == null) |
213 | { |
213 | { |
214 | 1.5.0/docs/api/java/lang/String.html">String identifier = repositoryService.storeRepositoryFile(stream, contentType, extension, size, name, "course.studies.plan " + c.getName(), ResourceAccessControlEnum.publicDomain, null, userSession); |
214 | 1.5.0/docs/api/java/lang/String.html">String identifier = repositoryService.storeRepositoryFile(stream, contentType, extension, size, name, "course.studies.plan " + c.getName(), ResourceAccessControlEnum.publicDomain, null, userSession); |
215 | c.setStudiesPlan(identifier); |
215 | c.setStudiesPlan(identifier); |
216 | } |
216 | } |
217 | else |
217 | else |
218 | { |
218 | { |
219 | repositoryService.updateRepositoryFile(c.getStudiesPlan(), stream, contentType, extension, size, name, "course.studies.plan " + c.getName(), ResourceAccessControlEnum.publicDomain); |
219 | repositoryService.updateRepositoryFile(c.getStudiesPlan(), stream, contentType, extension, size, name, "course.studies.plan " + c.getName(), ResourceAccessControlEnum.publicDomain); |
220 | } |
220 | } |
221 | htmlTrasformationResult = generateHtmlCache(userSession, c); |
221 | htmlTrasformationResult = generateHtmlCache(userSession, c); |
222 | //####New#### Generating XML with JaxB |
222 | //####New#### Generating XML with JaxB |
223 | //ISTO SO É CHAMADO NO CASO DE SE FAZER UPLOAD DE UM NOVO PLANO PELO MECANISMO ANTIGO |
223 | //ISTO SO É CHAMADO NO CASO DE SE FAZER UPLOAD DE UM NOVO PLANO PELO MECANISMO ANTIGO |
224 | generateXmlJaxbStudiesPlanVersionFromRepositoryOldPlanStream(userSession, c, forceUrlFichas, systemUrl); |
224 | generateXmlJaxbStudiesPlanVersionFromRepositoryOldPlanStream(userSession, c, forceUrlFichas, systemUrl); |
225 | } |
225 | } |
226 | return htmlTrasformationResult; |
226 | return htmlTrasformationResult; |
227 | } |
227 | } |
228 | 228 | ||
229 | 229 | ||
230 | 230 | ||
231 | private void generateCourseJson(Course cAux) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
231 | private void generateCourseJson(Course cAux) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
232 | CourseImpl c = (CourseImpl) DaoFactory.getCourseDaoImpl().narrow(cAux); |
232 | CourseImpl c = (CourseImpl) DaoFactory.getCourseDaoImpl().narrow(cAux); |
233 | 233 | ||
234 | if(c.getValidationRole() != null && c.getValidationRole().trim().length() > 0) |
234 | if(c.getValidationRole() != null && c.getValidationRole().trim().length() > 0) |
235 | { |
235 | { |
236 | List<Teacher> courseComissionProxys = DaoFactory.getUserDaoImpl().loadRoleTeachers(c.getValidationRole()); |
236 | List<Teacher> courseComissionProxys = DaoFactory.getUserDaoImpl().loadRoleTeachers(c.getValidationRole()); |
237 | List<Teacher> courseComission = new ArrayList<Teacher>(); |
237 | List<Teacher> courseComission = new ArrayList<Teacher>(); |
238 | for(Teacher t: courseComissionProxys) |
238 | for(Teacher t: courseComissionProxys) |
239 | { |
239 | { |
240 | courseComission.add(DaoFactory.getTeacherDaoImpl().narrow(t)); |
240 | courseComission.add(DaoFactory.getTeacherDaoImpl().narrow(t)); |
241 | } |
241 | } |
242 | c.setCourseComission(courseComission); |
242 | c.setCourseComission(courseComission); |
243 | } |
243 | } |
244 | //Getting Coordinator from proxy |
244 | //Getting Coordinator from proxy |
245 | Teacher t = c.getCoordinator(); |
245 | Teacher t = c.getCoordinator(); |
246 | if(t != null) |
246 | if(t != null) |
247 | t.getName(); |
247 | t.getName(); |
248 | else |
248 | else |
249 | { |
249 | { |
250 | logger.warn("Course does not have coordinator"); |
250 | logger.warn("Course does not have coordinator"); |
251 | } |
251 | } |
252 | 252 | ||
253 | 1.5.0/docs/api/java/lang/String.html">String jsonCourse = getGensonCourse().serialize(c); |
253 | 1.5.0/docs/api/java/lang/String.html">String jsonCourse = getGensonCourse().serialize(c); |
254 | c.setJson(jsonCourse); |
254 | c.setJson(jsonCourse); |
255 | } |
255 | } |
256 | 256 | ||
257 | private 1.5.0/docs/api/java/lang/String.html">String generateHtmlCache(UserSession userSession, Course c) { |
257 | private 1.5.0/docs/api/java/lang/String.html">String generateHtmlCache(UserSession userSession, Course c) { |
258 | 1.5.0/docs/api/java/lang/String.html">String htmlTrasformationResult = null; |
258 | 1.5.0/docs/api/java/lang/String.html">String htmlTrasformationResult = null; |
259 | 5+0%2Fdocs%2Fapi+InputStream">InputStream stream;IRepositoryFile repositoryFile = repositoryService.load(c.getStudiesPlan(),userSession); |
259 | 5+0%2Fdocs%2Fapi+InputStream">InputStream stream;IRepositoryFile repositoryFile = repositoryService.load(c.getStudiesPlan(),userSession); |
260 | stream = repositoryFile.getInput(); |
260 | stream = repositoryFile.getInput(); |
261 | try |
261 | try |
262 | { |
262 | { |
263 | 5+0%2Fdocs%2Fapi+Document">Document dom = Dom4jUtil.parse(stream); |
263 | 5+0%2Fdocs%2Fapi+Document">Document dom = Dom4jUtil.parse(stream); |
264 | Map<String,Object> parameters = new HashMap<String,Object>(); |
264 | Map<String,Object> parameters = new HashMap<String,Object>(); |
265 | parameters.put("COURSE_SIGES_CODE",c.getCode()); |
265 | parameters.put("COURSE_SIGES_CODE",c.getCode()); |
266 | 1.5.0/docs/api/java/lang/String.html">String html = Dom4jUtil.styleDocument(dom, Globals.TEMPLATE_COURSE_XSL_PATH,parameters); |
266 | 1.5.0/docs/api/java/lang/String.html">String html = Dom4jUtil.styleDocument(dom, Globals.TEMPLATE_COURSE_XSL_PATH,parameters); |
267 | c.setCacheWebDocument(html); |
267 | c.setCacheWebDocument(html); |
268 | } |
268 | } |
269 | catch (1.5.0/docs/api/java/lang/Exception.html">Exception e) |
269 | catch (1.5.0/docs/api/java/lang/Exception.html">Exception e) |
270 | { |
270 | { |
271 | 1.5.0/docs/api/java/io/StringWriter.html">StringWriter writer = new 1.5.0/docs/api/java/io/StringWriter.html">StringWriter(); |
271 | 1.5.0/docs/api/java/io/StringWriter.html">StringWriter writer = new 1.5.0/docs/api/java/io/StringWriter.html">StringWriter(); |
272 | 1.5.0/docs/api/java/io/PrintWriter.html">PrintWriter printWriter = new 1.5.0/docs/api/java/io/PrintWriter.html">PrintWriter(writer); |
272 | 1.5.0/docs/api/java/io/PrintWriter.html">PrintWriter printWriter = new 1.5.0/docs/api/java/io/PrintWriter.html">PrintWriter(writer); |
273 | e.printStackTrace(printWriter); |
273 | e.printStackTrace(printWriter); |
274 | htmlTrasformationResult = "<div class=\"error\"><pre>" + e.toString() + "\n" + printWriter.toString() + "</pre></div>"; |
274 | htmlTrasformationResult = "<div class=\"error\"><pre>" + e.toString() + "\n" + printWriter.toString() + "</pre></div>"; |
275 | printWriter.close(); |
275 | printWriter.close(); |
276 | } |
276 | } |
277 | try |
277 | try |
278 | { |
278 | { |
279 | stream.close(); |
279 | stream.close(); |
280 | } |
280 | } |
281 | catch (1.5.0/docs/api/java/io/IOException.html">IOException e) |
281 | catch (1.5.0/docs/api/java/io/IOException.html">IOException e) |
282 | { |
282 | { |
283 | logger.error(e,e); |
283 | logger.error(e,e); |
284 | } |
284 | } |
285 | return htmlTrasformationResult; |
285 | return htmlTrasformationResult; |
286 | } |
286 | } |
287 | 287 | ||
288 | /** |
288 | /** |
289 | * ##NEW METHOD### |
289 | * ##NEW METHOD### |
290 | * Gera o XML normalizado para o JAXB a partir do XML importado do XML do plano XML quese usou no upload |
290 | * Gera o XML normalizado para o JAXB a partir do XML importado do XML do plano XML quese usou no upload |
291 | * para garantir que está bem formado |
291 | * para garantir que está bem formado |
292 | * @param userSession |
292 | * @param userSession |
293 | * @param c |
293 | * @param c |
294 | * @return |
294 | * @return |
295 | * @throws JAXBException if XML is not weel formed |
295 | * @throws JAXBException if XML is not weel formed |
296 | */ |
296 | */ |
297 | private void generateXmlJaxbStudiesPlanVersionFromRepositoryOldPlanStream(UserSession userSession, Course c, boolean forceFichaCurricularUrlSet, 1.5.0/docs/api/java/lang/String.html">String systemUrlForUnitPrograms) throws JAXBException |
297 | private void generateXmlJaxbStudiesPlanVersionFromRepositoryOldPlanStream(UserSession userSession, Course c, boolean forceFichaCurricularUrlSet, 1.5.0/docs/api/java/lang/String.html">String systemUrlForUnitPrograms) throws JAXBException |
298 | { |
298 | { |
299 | CourseStudiesPlan courseStudiesPlan; |
299 | CourseStudiesPlan courseStudiesPlan; |
300 | if(c.getStudiesPlan() == null || c.getStudiesPlan().trim().length() == 0) |
300 | if(c.getStudiesPlan() == null || c.getStudiesPlan().trim().length() == 0) |
301 | { |
301 | { |
302 | //ESTE É O STREAM DO PLANO DE UPLOAD |
302 | //ESTE É O STREAM DO PLANO DE UPLOAD |
303 | logger.warn("Course does not have studies plan XML file stream to use in update"); |
303 | logger.warn("Course does not have studies plan XML file stream to use in update"); |
304 | return; |
304 | return; |
305 | } |
305 | } |
306 | 306 | ||
307 | if(c.getStudiesPlans() == null || c.getStudiesPlans().size() == 0) |
307 | if(c.getStudiesPlans() == null || c.getStudiesPlans().size() == 0) |
308 | { |
308 | { |
309 | logger.info("Generating first study plan"); |
309 | logger.info("Generating first study plan"); |
310 | courseStudiesPlan = DomainObjectFactory.createCourseStudiesPlanImpl(); |
310 | courseStudiesPlan = DomainObjectFactory.createCourseStudiesPlanImpl(); |
311 | courseStudiesPlan.setVersion(1); |
311 | courseStudiesPlan.setVersion(1); |
312 | courseStudiesPlan.setVersionDescription("Auto gerado durante a importação de um XML com o plano de estudos a " + new 5+0%2Fdocs%2Fapi+Date">Date().toString()); |
312 | courseStudiesPlan.setVersionDescription("Auto gerado durante a importação de um XML com o plano de estudos a " + new 5+0%2Fdocs%2Fapi+Date">Date().toString()); |
313 | courseStudiesPlan.setCourse(c); |
313 | courseStudiesPlan.setCourse(c); |
314 | if(c.getStudiesPlans() == null) |
314 | if(c.getStudiesPlans() == null) |
315 | c.setStudiesPlans(new HashSet<CourseStudiesPlan>()); |
315 | c.setStudiesPlans(new HashSet<CourseStudiesPlan>()); |
316 | c.getStudiesPlans().add(courseStudiesPlan); |
316 | c.getStudiesPlans().add(courseStudiesPlan); |
317 | DaoFactory.getCourseStudiesPlanDaoImpl().save(courseStudiesPlan); |
317 | DaoFactory.getCourseStudiesPlanDaoImpl().save(courseStudiesPlan); |
318 | } |
318 | } |
319 | else |
319 | else |
320 | { |
320 | { |
321 | courseStudiesPlan = c.getStudiesPlans().iterator().next(); |
321 | courseStudiesPlan = c.getStudiesPlans().iterator().next(); |
322 | logger.info("Updating Study Plan version " + courseStudiesPlan.getVersion()); |
322 | logger.info("Updating Study Plan version " + courseStudiesPlan.getVersion()); |
323 | } |
323 | } |
324 | 324 | ||
325 | 5+0%2Fdocs%2Fapi+InputStream">InputStream stream; |
325 | 5+0%2Fdocs%2Fapi+InputStream">InputStream stream; |
326 | IRepositoryFile repositoryFile = repositoryService.load(c.getStudiesPlan(),userSession); |
326 | IRepositoryFile repositoryFile = repositoryService.load(c.getStudiesPlan(),userSession); |
327 | long lastVersion = repositoryService.loadView(c.getStudiesPlan()).getLastVersion().getId(); |
327 | long lastVersion = repositoryService.loadView(c.getStudiesPlan()).getLastVersion().getId(); |
328 | //stream = repositoryFile.getInput(); |
328 | //stream = repositoryFile.getInput(); |
329 | //TODO TIRAR |
329 | //TODO TIRAR |
330 | //JUST FOR DEBUG |
330 | //JUST FOR DEBUG |
331 | /* try { |
331 | /* try { |
332 | System.out.println(StreamsUtils.readString(stream)); |
332 | System.out.println(StreamsUtils.readString(stream)); |
333 | stream.close(); |
333 | stream.close(); |
334 | } catch (IOException e) { |
334 | } catch (IOException e) { |
335 | e.printStackTrace(); |
335 | e.printStackTrace(); |
336 | }*/ |
336 | }*/ |
337 | repositoryFile = repositoryService.load(c.getStudiesPlan(),userSession); |
337 | repositoryFile = repositoryService.load(c.getStudiesPlan(),userSession); |
338 | stream = repositoryFile.getInput(); |
338 | stream = repositoryFile.getInput(); |
339 | 339 | ||
340 | try { |
340 | try { |
341 | JAXBContext jc = JAXBContext.newInstance(Curso.class); |
341 | JAXBContext jc = JAXBContext.newInstance(Curso.class); |
342 | Unmarshaller unmarshaller = jc.createUnmarshaller(); |
342 | Unmarshaller unmarshaller = jc.createUnmarshaller(); |
343 | //Just in case lets update SigesCode |
343 | //Just in case lets update SigesCode |
344 | Curso curso = (Curso) unmarshaller.unmarshal(stream); |
344 | Curso curso = (Curso) unmarshaller.unmarshal(stream); |
345 | curso.setSiges(c.getCode()); |
345 | curso.setSiges(c.getCode()); |
346 | curso.setNome(c.getName()); |
346 | curso.setNome(c.getName()); |
347 | curso.setDep(c.getArea()); |
347 | curso.setDep(c.getArea()); |
348 | 348 | ||
349 | //##NOVO PARA GERAR LINK SE NAO EXISTIR |
349 | //##NOVO PARA GERAR LINK SE NAO EXISTIR |
350 | generateAutoUrlFichasCurriculares(curso,systemUrlForUnitPrograms,forceFichaCurricularUrlSet); |
350 | generateAutoUrlFichasCurriculares(curso,systemUrlForUnitPrograms,forceFichaCurricularUrlSet); |
351 | 351 | ||
352 | Marshaller marshaller = jc.createMarshaller(); |
352 | Marshaller marshaller = jc.createMarshaller(); |
353 | marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); |
353 | marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); |
354 | 1.5.0/docs/api/java/io/StringWriter.html">StringWriter sw = new 1.5.0/docs/api/java/io/StringWriter.html">StringWriter(); |
354 | 1.5.0/docs/api/java/io/StringWriter.html">StringWriter sw = new 1.5.0/docs/api/java/io/StringWriter.html">StringWriter(); |
355 | marshaller.marshal(curso, sw); |
355 | marshaller.marshal(curso, sw); |
356 | //SETTING XML in COURSE STUDIES PLAN |
356 | //SETTING XML in COURSE STUDIES PLAN |
357 | courseStudiesPlan.setXml(sw.toString()); |
357 | courseStudiesPlan.setXml(sw.toString()); |
358 | 358 | ||
359 | 359 | ||
360 | 1.5.0/docs/api/java/lang/String.html">String json = CursoImpl.getGensonPlanoEstudosParaApiJsonWS().serialize(curso); |
360 | 1.5.0/docs/api/java/lang/String.html">String json = CursoImpl.getGensonPlanoEstudosParaApiJsonWS().serialize(curso); |
361 | //SETTING JSON in COURSE STUDIES PLAN |
361 | //SETTING JSON in COURSE STUDIES PLAN |
362 | courseStudiesPlan.setJson(json); |
362 | courseStudiesPlan.setJson(json); |
363 | 363 | ||
364 | } catch (JAXBException e) { |
364 | } catch (JAXBException e) { |
365 | logger.error(e,e); |
365 | logger.error(e,e); |
366 | 1.5.0/docs/api/java/lang/System.html">System.out.print("check XML for possible errors for repositoryStream:" + c.getStudiesPlan() + " file version: " + lastVersion); |
366 | 1.5.0/docs/api/java/lang/System.html">System.out.print("check XML for possible errors for repositoryStream:" + c.getStudiesPlan() + " file version: " + lastVersion); |
367 | throw e; |
367 | throw e; |
368 | } |
368 | } |
369 | try |
369 | try |
370 | { |
370 | { |
371 | stream.close(); |
371 | stream.close(); |
372 | } |
372 | } |
373 | catch (1.5.0/docs/api/java/io/IOException.html">IOException e) |
373 | catch (1.5.0/docs/api/java/io/IOException.html">IOException e) |
374 | { |
374 | { |
375 | logger.error(e,e); |
375 | logger.error(e,e); |
376 | } |
376 | } |
377 | } |
377 | } |
378 | 378 | ||
379 | 379 | ||
380 | /** |
380 | /** |
381 | * Apenas é chamado quando se tenta injectar um programa a partir de um upload que foi feito |
381 | * Apenas é chamado quando se tenta injectar um programa a partir de um upload que foi feito |
382 | * pelo user ou pela sincronização remota |
382 | * pelo user ou pela sincronização remota |
383 | * @param curso |
383 | * @param curso |
384 | * @param systemUrl |
384 | * @param systemUrl |
385 | * @param force |
385 | * @param force |
386 | */ |
386 | */ |
387 | private void generateAutoUrlFichasCurriculares(Curso curso,1.5.0/docs/api/java/lang/String.html">String systemUrl,boolean force) |
387 | private void generateAutoUrlFichasCurriculares(Curso curso,1.5.0/docs/api/java/lang/String.html">String systemUrl,boolean force) |
388 | { |
388 | { |
389 | for(Curso.Semestre s :curso.getSemestre()) |
389 | for(Curso.Semestre s :curso.getSemestre()) |
390 | { |
390 | { |
391 | for(Curso.Semestre.Perfil p :s.getPerfil()) |
391 | for(Curso.Semestre.Perfil p :s.getPerfil()) |
392 | { |
392 | { |
393 | for(UnidadeType unidadeType : p.getUnidade()) |
393 | for(UnidadeType unidadeType : p.getUnidade()) |
394 | { |
394 | { |
395 | generateAutoUrlUnidade(unidadeType,systemUrl,curso,s,force); |
395 | generateAutoUrlUnidade(unidadeType,systemUrl,curso,s,force); |
396 | } |
396 | } |
397 | } |
397 | } |
398 | for(UnidadeType unidadeType : s.getUnidade()) |
398 | for(UnidadeType unidadeType : s.getUnidade()) |
399 | { |
399 | { |
400 | generateAutoUrlUnidade(unidadeType,systemUrl,curso,s,force); |
400 | generateAutoUrlUnidade(unidadeType,systemUrl,curso,s,force); |
401 | } |
401 | } |
402 | } |
402 | } |
403 | } |
403 | } |
404 | 404 | ||
405 | private void generateAutoUrlUnidade(UnidadeType unidadeType,1.5.0/docs/api/java/lang/String.html">String systemUrl,Curso curso,Curso.Semestre semestre,boolean force) |
405 | private void generateAutoUrlUnidade(UnidadeType unidadeType,1.5.0/docs/api/java/lang/String.html">String systemUrl,Curso curso,Curso.Semestre semestre,boolean force) |
406 | { |
406 | { |
407 | if(force || unidadeType.getUrlFichaCurricular() == null || unidadeType.getUrlFichaCurricular().trim().length()==0) |
407 | if(force || unidadeType.getUrlFichaCurricular() == null || unidadeType.getUrlFichaCurricular().trim().length()==0) |
408 | { |
408 | { |
409 | logger.info("GENERATING FICHA CURRICULAR URL For " + unidadeType.getNome()); |
409 | logger.info("GENERATING FICHA CURRICULAR URL For " + unidadeType.getNome()); |
410 | 1.5.0/docs/api/java/lang/String.html">String url = systemUrl != null ? systemUrl : ""; |
410 | 1.5.0/docs/api/java/lang/String.html">String url = systemUrl != null ? systemUrl : ""; |
411 | if(!url.endsWith("/")) |
411 | if(!url.endsWith("/")) |
412 | url = url + "/"; |
412 | url = url + "/"; |
413 | 413 | ||
414 | //Nao fornece o ano pois o servico irá assumir o ultimo |
414 | //Nao fornece o ano pois o servico irá assumir o ultimo |
415 | unidadeType.setUrlFichaCurricular(url + "startLoadCourseUnitProgramSiges.do?unitCode=" + unidadeType.getSiges() + "&courseCode=" + curso.getSiges() + "&semestre=" + semestre.getId()); |
415 | unidadeType.setUrlFichaCurricular(url + "startLoadCourseUnitProgramSiges.do?unitCode=" + unidadeType.getSiges() + "&courseCode=" + curso.getSiges() + "&semestre=" + semestre.getId()); |
416 | unidadeType.setUrlUnidadeCurricular(url + "startLoadCourseUnitSiges.do?unitCode=" + unidadeType.getSiges() + "&courseCode=" + curso.getSiges() + "&semestre=" + semestre.getId()); |
416 | unidadeType.setUrlUnidadeCurricular(url + "startLoadCourseUnitSiges.do?unitCode=" + unidadeType.getSiges() + "&courseCode=" + curso.getSiges() + "&semestre=" + semestre.getId()); |
417 | } |
417 | } |
418 | } |
418 | } |
419 | 419 | ||
420 | 420 | ||
421 | private static Genson getGensonCourse(){ |
421 | private static Genson getGensonCourse(){ |
422 | Genson genson = new GensonBuilder() |
422 | Genson genson = new GensonBuilder() |
423 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
423 | .exclude(5+0%2Fdocs%2Fapi+Object">Object.class) |
424 | .useFields(false) |
424 | .useFields(false) |
425 | .useMethods(true) |
425 | .useMethods(true) |
426 | .setMethodFilter(VisibilityFilter.PACKAGE_PUBLIC) |
426 | .setMethodFilter(VisibilityFilter.PACKAGE_PUBLIC) |
427 | .exclude("admin") |
427 | .exclude("admin") |
428 | .exclude("autoBlock") |
428 | .exclude("autoBlock") |
429 | .exclude("autoBlockMode") |
429 | .exclude("autoBlockMode") |
430 | .exclude("manualBlock") |
430 | .exclude("manualBlock") |
431 | .exclude("newUser") |
431 | .exclude("newUser") |
432 | .exclude("student") |
432 | .exclude("student") |
433 | .exclude("superuser") |
433 | .exclude("superuser") |
434 | .exclude("superuserOrAdmin") |
434 | .exclude("superuserOrAdmin") |
435 | .exclude("teacher") |
435 | .exclude("teacher") |
436 | .exclude("unitCheck") |
436 | .exclude("unitCheck") |
437 | .exclude("id") |
437 | .exclude("id") |
438 | 438 | ||
439 | /* .exclude(Course.class) |
439 | /* .exclude(Course.class) |
440 | .exclude(CourseImpl.class) |
440 | .exclude(CourseImpl.class) |
441 | .exclude(GenericUser.class) |
441 | .exclude(GenericUser.class) |
442 | .exclude(User.class) |
442 | .exclude(User.class) |
443 | .exclude(UserImpl.class) |
443 | .exclude(UserImpl.class) |
444 | .exclude(Teacher.class) |
444 | .exclude(Teacher.class) |
445 | .exclude(TeacherImpl.class) |
445 | .exclude(TeacherImpl.class) |
446 | .exclude(SigesUser.class) |
446 | .exclude(SigesUser.class) |
447 | .exclude(SigesUserImpl.class) |
447 | .exclude(SigesUserImpl.class) |
448 | .exclude(GenericUser.class) |
448 | .exclude(GenericUser.class) |
449 | .exclude(GenericUserImpl.class) |
449 | .exclude(GenericUserImpl.class) |
450 | */ |
450 | */ |
451 | .exclude("id", Course.class) |
451 | .exclude("id", Course.class) |
452 | .exclude("status", Course.class) |
452 | .exclude("status", Course.class) |
453 | .exclude("showStudiesPlan", Course.class) |
453 | .exclude("showStudiesPlan", Course.class) |
454 | .include("degreeForJsonApi", CourseImpl.class) |
454 | .include("degreeForJsonApi", CourseImpl.class) |
455 | .include("degreeForJsonApiEn", CourseImpl.class) |
455 | .include("degreeForJsonApiEn", CourseImpl.class) |
456 | .include("degreeForJsonApiEs", CourseImpl.class) |
456 | .include("degreeForJsonApiEs", CourseImpl.class) |
457 | .include("degreeForJsonApiFr", CourseImpl.class) |
457 | .include("degreeForJsonApiFr", CourseImpl.class) |
458 | .include("schoolForJsonApi", CourseImpl.class) |
458 | .include("schoolForJsonApi", CourseImpl.class) |
459 | .include("statusForJsonApi", CourseImpl.class) |
459 | .include("statusForJsonApi", CourseImpl.class) |
460 | 460 | ||
461 | 461 | ||
462 | .include("name", Course.class) |
462 | .include("name", Course.class) |
463 | .include("nameEn", Course.class) |
463 | .include("nameEn", Course.class) |
464 | .include("nameEs", Course.class) |
464 | .include("nameEs", Course.class) |
465 | .include("nameFr", Course.class) |
465 | .include("nameFr", Course.class) |
466 | .include("department", Course.class) |
466 | .include("department", Course.class) |
467 | .exclude("active", CourseDepartment.class) |
467 | .exclude("active", CourseDepartment.class) |
468 | .include("sigla", CourseDepartment.class) |
468 | .include("sigla", CourseDepartment.class) |
469 | .include("name", CourseDepartment.class) |
469 | .include("name", CourseDepartment.class) |
470 | .include("nameEn", CourseDepartment.class) |
470 | .include("nameEn", CourseDepartment.class) |
471 | .include("nameEs", CourseDepartment.class) |
471 | .include("nameEs", CourseDepartment.class) |
472 | .include("nameFr", CourseDepartment.class) |
472 | .include("nameFr", CourseDepartment.class) |
473 | .include("code", Course.class) |
473 | .include("code", Course.class) |
474 | .include("validationRole", Course.class) |
474 | .include("validationRole", Course.class) |
475 | 475 | ||
476 | .include("courseComission", CourseImpl.class) |
476 | .include("courseComission", CourseImpl.class) |
477 | 477 | ||
478 | .include("name", GenericUser.class) |
478 | .include("name", GenericUser.class) |
479 | .include("email", GenericUser.class) |
479 | .include("email", GenericUser.class) |
480 | .include("sigesCode", SigesUser.class) |
480 | .include("sigesCode", SigesUser.class) |
481 | .include("coordinator", Course.class) |
481 | .include("coordinator", Course.class) |
482 | .create(); |
482 | .create(); |
483 | 483 | ||
484 | return genson; |
484 | return genson; |
485 | } |
485 | } |
486 | 486 | ||
487 | 487 | ||
488 | 488 | ||
489 | public List<CourseView> loadCourses() throws ServiceException |
489 | public List<CourseView> loadCourses() throws ServiceException |
490 | { |
490 | { |
491 | List<Course> courses = DaoFactory.getCourseDaoImpl().findAllOrderByName(); |
491 | List<Course> courses = DaoFactory.getCourseDaoImpl().findAllOrderByName(); |
492 | List<CourseView> courseViews = new ArrayList<CourseView>(); |
492 | List<CourseView> courseViews = new ArrayList<CourseView>(); |
493 | for(Course c: courses) |
493 | for(Course c: courses) |
494 | { |
494 | { |
495 | CourseView courseView = new CourseView(c); |
495 | CourseView courseView = new CourseView(c); |
496 | courseViews.add(courseView); |
496 | courseViews.add(courseView); |
497 | } |
497 | } |
498 | return courseViews; |
498 | return courseViews; |
499 | } |
499 | } |
500 | 500 | ||
501 | public List<CourseView> loadCoursesImportYearArea(1.5.0/docs/api/java/lang/String.html">String importYear, 1.5.0/docs/api/java/lang/String.html">String area) throws ServiceException |
501 | public List<CourseView> loadCoursesImportYearArea(1.5.0/docs/api/java/lang/String.html">String importYear, 1.5.0/docs/api/java/lang/String.html">String area) throws ServiceException |
502 | { |
502 | { |
503 | return loadCoursesImportYearAreaInstitution(importYear, area,null); |
503 | return loadCoursesImportYearAreaInstitution(importYear, area,null); |
504 | } |
504 | } |
505 | 505 | ||
506 | public List<CourseView> loadCoursesImportYearAreaInstitution(1.5.0/docs/api/java/lang/String.html">String importYear, 1.5.0/docs/api/java/lang/String.html">String area,1.5.0/docs/api/java/lang/String.html">String institutionCode) throws ServiceException |
506 | public List<CourseView> loadCoursesImportYearAreaInstitution(1.5.0/docs/api/java/lang/String.html">String importYear, 1.5.0/docs/api/java/lang/String.html">String area,1.5.0/docs/api/java/lang/String.html">String institutionCode) throws ServiceException |
507 | { |
507 | { |
508 | List<Course> courses = DaoFactory.getCourseDaoImpl().findAllOrderByName(importYear,area,null,institutionCode); |
508 | List<Course> courses = DaoFactory.getCourseDaoImpl().findAllOrderByName(importYear,area,null,institutionCode); |
509 | List<CourseView> courseViews = new ArrayList<CourseView>(); |
509 | List<CourseView> courseViews = new ArrayList<CourseView>(); |
510 | for(Course c: courses) |
510 | for(Course c: courses) |
511 | { |
511 | { |
512 | CourseView courseView = new CourseView(c); |
512 | CourseView courseView = new CourseView(c); |
513 | courseViews.add(courseView); |
513 | courseViews.add(courseView); |
514 | } |
514 | } |
515 | return courseViews; |
515 | return courseViews; |
516 | } |
516 | } |
517 | 517 | ||
518 | public List<CourseView> loadCoursesImportYear() throws ServiceException |
518 | public List<CourseView> loadCoursesImportYear() throws ServiceException |
519 | { |
519 | { |
520 | 1.5.0/docs/api/java/lang/String.html">String importYearIntranet = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear(); |
520 | 1.5.0/docs/api/java/lang/String.html">String importYearIntranet = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear(); |
521 | List<Course> courses = DaoFactory.getCourseDaoImpl().findAllOrderByName(importYearIntranet); |
521 | List<Course> courses = DaoFactory.getCourseDaoImpl().findAllOrderByName(importYearIntranet); |
522 | List<CourseView> courseViews = new ArrayList<CourseView>(); |
522 | List<CourseView> courseViews = new ArrayList<CourseView>(); |
523 | for(Course c: courses) |
523 | for(Course c: courses) |
524 | { |
524 | { |
525 | CourseView courseView = new CourseView(c); |
525 | CourseView courseView = new CourseView(c); |
526 | courseViews.add(courseView); |
526 | courseViews.add(courseView); |
527 | } |
527 | } |
528 | return courseViews; |
528 | return courseViews; |
529 | } |
529 | } |
530 | public List<CourseView> loadCoursesImportYearByType(1.5.0/docs/api/java/lang/String.html">String type) throws ServiceException |
530 | public List<CourseView> loadCoursesImportYearByType(1.5.0/docs/api/java/lang/String.html">String type) throws ServiceException |
531 | { |
531 | { |
532 | 1.5.0/docs/api/java/lang/String.html">String importYearIntranet = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear(); |
532 | 1.5.0/docs/api/java/lang/String.html">String importYearIntranet = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear(); |
533 | List<Course> courses = DaoFactory.getCourseDaoImpl().findAllOrderByNameEvenWithoutCourseUnit(importYearIntranet,null,type); |
533 | List<Course> courses = DaoFactory.getCourseDaoImpl().findAllOrderByNameEvenWithoutCourseUnit(importYearIntranet,null,type); |
534 | List<CourseView> courseViews = new ArrayList<CourseView>(); |
534 | List<CourseView> courseViews = new ArrayList<CourseView>(); |
535 | for(Course c: courses) |
535 | for(Course c: courses) |
536 | { |
536 | { |
537 | CourseView courseView = new CourseView(c); |
537 | CourseView courseView = new CourseView(c); |
538 | courseViews.add(courseView); |
538 | courseViews.add(courseView); |
539 | } |
539 | } |
540 | return courseViews; |
540 | return courseViews; |
541 | } |
541 | } |
542 | 542 | ||
543 | public List<CourseView> loadActiveCoursesByType(1.5.0/docs/api/java/lang/String.html">String type) throws ServiceException |
543 | public List<CourseView> loadActiveCoursesByType(1.5.0/docs/api/java/lang/String.html">String type) throws ServiceException |
544 | { |
544 | { |
545 | 1.5.0/docs/api/java/lang/String.html">String importYearIntranet = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear(); |
545 | 1.5.0/docs/api/java/lang/String.html">String importYearIntranet = DaoFactory.getConfigurationDaoImpl().getInterfaceImportYear(); |
546 | List<Course> courses = DaoFactory.getCourseDaoImpl().findAllActiveOrderByNameEvenWithoutCourseUnit(importYearIntranet,null,type); |
546 | List<Course> courses = DaoFactory.getCourseDaoImpl().findAllActiveOrderByNameEvenWithoutCourseUnit(importYearIntranet,null,type); |
547 | List<CourseView> courseViews = new ArrayList<CourseView>(); |
547 | List<CourseView> courseViews = new ArrayList<CourseView>(); |
548 | for(Course c: courses) |
548 | for(Course c: courses) |
549 | { |
549 | { |
550 | CourseView courseView = new CourseView(c); |
550 | CourseView courseView = new CourseView(c); |
551 | courseViews.add(courseView); |
551 | courseViews.add(courseView); |
552 | } |
552 | } |
553 | return courseViews; |
553 | return courseViews; |
554 | } |
554 | } |
555 | 555 | ||
556 | 556 | ||
557 | 557 | ||
558 | /** JSON API **/ |
558 | /** JSON API **/ |
559 | /** |
559 | /** |
560 | * @SERVICE@ |
560 | * @SERVICE@ |
561 | * |
561 | * |
562 | * @param school |
562 | * @param school |
563 | * @param type |
563 | * @param type |
564 | * @return |
564 | * @return |
565 | * @throws JSONException |
565 | * @throws JSONException |
566 | */ |
566 | */ |
567 | public JSONObject getActiveCoursesForJsonApi(1.5.0/docs/api/java/lang/String.html">String school,1.5.0/docs/api/java/lang/String.html">String type) throws JSONException { |
567 | public JSONObject getActiveCoursesForJsonApi(1.5.0/docs/api/java/lang/String.html">String school,1.5.0/docs/api/java/lang/String.html">String type) throws JSONException { |
568 | 1.5.0/docs/api/java/lang/String.html">String institutionalCode = null; |
568 | 1.5.0/docs/api/java/lang/String.html">String institutionalCode = null; |
569 | 1.5.0/docs/api/java/lang/String.html">String degree = null; |
569 | 1.5.0/docs/api/java/lang/String.html">String degree = null; |
570 | if(school != null && school.length() > 0) |
570 | if(school != null && school.length() > 0) |
571 | institutionalCode = ConfigProperties.getProperty("institution.code.prefix.inverse." + school); |
571 | institutionalCode = ConfigProperties.getProperty("institution.code.prefix.inverse." + school); |
572 | 572 | ||
573 | if(type != null && type.length() > 0) |
573 | if(type != null && type.length() > 0) |
574 | degree = ConfigProperties.getProperty("course.inverse." + type); |
574 | degree = ConfigProperties.getProperty("course.inverse." + type); |
575 | 575 | ||
576 | List<Course> courses = DaoFactory.getCourseDaoImpl().findAllShowStudiesPlanCoursesOrderByNameEvenWithoutCourseUnit(institutionalCode, degree); |
576 | List<Course> courses = DaoFactory.getCourseDaoImpl().findAllShowStudiesPlanCoursesOrderByNameEvenWithoutCourseUnit(institutionalCode, degree); |
577 | JSONObject coursesResponse = new JSONObject(); |
577 | JSONObject coursesResponse = new JSONObject(); |
578 | 578 | ||
579 | JSONArray coursesArray = new JSONArray(); |
579 | JSONArray coursesArray = new JSONArray(); |
580 | for(Course cAux: courses) |
580 | for(Course cAux: courses) |
581 | { |
581 | { |
582 | CourseImpl c = (CourseImpl) DaoFactory.getCourseDaoImpl().narrow(cAux); |
582 | CourseImpl c = (CourseImpl) DaoFactory.getCourseDaoImpl().narrow(cAux); |
583 | JSONObject courseJson = new JSONObject(); |
583 | JSONObject courseJson = new JSONObject(); |
584 | courseJson.put("name",c.getName()); |
584 | courseJson.put("name",c.getName()); |
585 | courseJson.put("code",c.getCode()); |
585 | courseJson.put("code",c.getCode()); |
586 | courseJson.put("schoolForJsonApi",c.getSchoolForJsonApi()); |
586 | courseJson.put("schoolForJsonApi",c.getSchoolForJsonApi()); |
587 | courseJson.put("degreeForJsonApi",c.getDegreeForJsonApi()); |
587 | courseJson.put("degreeForJsonApi",c.getDegreeForJsonApi()); |
588 | courseJson.put("degreeForJsonApiEn",c.getDegreeForJsonApiEn()); |
588 | courseJson.put("degreeForJsonApiEn",c.getDegreeForJsonApiEn()); |
589 | courseJson.put("degreeForJsonApiEs",c.getDegreeForJsonApiEs()); |
589 | courseJson.put("degreeForJsonApiEs",c.getDegreeForJsonApiEs()); |
590 | courseJson.put("degreeForJsonApiFr",c.getDegreeForJsonApiFr()); |
590 | courseJson.put("degreeForJsonApiFr",c.getDegreeForJsonApiFr()); |
591 | courseJson.put("statusForJsonApi",c.getStatusForJsonApi()); |
591 | courseJson.put("statusForJsonApi",c.getStatusForJsonApi()); |
592 | courseJson.put("getDetailedInfoUrl","/wsjson/api?service=getCourse&code=" + c.getCode()); |
592 | courseJson.put("getDetailedInfoUrl","/wsjson/api?service=getCourse&code=" + c.getCode()); |
593 | coursesArray.put(courseJson); |
593 | coursesArray.put(courseJson); |
594 | 594 | ||
595 | } |
595 | } |
596 | coursesResponse.put("status","ok"); |
596 | coursesResponse.put("status","ok"); |
597 | coursesResponse.put("courses",coursesArray); |
597 | coursesResponse.put("courses",coursesArray); |
598 | 598 | ||
599 | return coursesResponse; |
599 | return coursesResponse; |
600 | } |
600 | } |
601 | 601 | ||
602 | /** |
602 | /** |
603 | * |
603 | * |
604 | * * Serviço invocado para obter o JSON de um curso |
604 | * * Serviço invocado para obter o JSON de um curso |
605 | * O JSON tem dois campos o courseInfo e o plano de estudos colocados separadamente |
605 | * O JSON tem dois campos o courseInfo e o plano de estudos colocados separadamente |
606 | * |
606 | * |
607 | * Atenção o plano de estudos usado é o ultimo considerando o seu ID |
607 | * Atenção o plano de estudos usado é o ultimo considerando o seu ID |
608 | * Nota: O plano de Estudos é uma classe persistente que tem apenas versão e descrição |
608 | * Nota: O plano de Estudos é uma classe persistente que tem apenas versão e descrição |
609 | * deverá ter como campo o XML e o JSON já gerados do plano de estudos que comporta |
609 | * deverá ter como campo o XML e o JSON já gerados do plano de estudos que comporta |
610 | * |
610 | * |
611 | * //TODO REVER |
611 | * //TODO REVER |
612 | * @param code |
612 | * @param code |
613 | * @return |
613 | * @return |
614 | * @throws JSONException |
614 | * @throws JSONException |
615 | * @throws IOException |
615 | * @throws IOException |
616 | * @throws JAXBException |
616 | * @throws JAXBException |
617 | */ |
617 | */ |
618 | public JSONObject getCourseDetailForJsonApi(1.5.0/docs/api/java/lang/String.html">String code) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException, JAXBException { |
618 | public JSONObject getCourseDetailForJsonApi(1.5.0/docs/api/java/lang/String.html">String code) throws JSONException, 1.5.0/docs/api/java/io/IOException.html">IOException, JAXBException { |
619 | 619 | ||
620 | Course course = DaoFactory.getCourseDaoImpl().findCourseByCode(code); |
620 | Course course = DaoFactory.getCourseDaoImpl().findCourseByCode(code); |
621 | 621 | ||
622 | 622 | ||
623 | JSONObject coursesResponse = new JSONObject(); |
623 | JSONObject coursesResponse = new JSONObject(); |
624 | 624 | ||
625 | generateCourseJson(course); |
625 | generateCourseJson(course); |
626 | 626 | ||
627 | //if(course.toJson() == null) |
627 | //if(course.toJson() == null) |
628 | //{ |
628 | //{ |
629 | // logger.info("status JSON NOT EXIST FOR STUDIES PLAN IN THIS COURSE, will generate"); |
629 | // logger.info("status JSON NOT EXIST FOR STUDIES PLAN IN THIS COURSE, will generate"); |
630 | // new CoursesService().generateCourseJson(course); |
630 | // new CoursesService().generateCourseJson(course); |
631 | //} |
631 | //} |
632 | 632 | ||
633 | if(course.getJson() != null) |
633 | if(course.getJson() != null) |
634 | { |
634 | { |
635 | JSONObject courseObj = new JSONObject(course.getJson()); |
635 | JSONObject courseObj = new JSONObject(course.getJson()); |
636 | coursesResponse.put("courseInfo",courseObj); |
636 | coursesResponse.put("courseInfo",courseObj); |
637 | //Este caso apenas se dá se o plano nunca tiver sido editado ou sincronizado |
637 | //Este caso apenas se dá se o plano nunca tiver sido editado ou sincronizado |
638 | //Nesse caso o sistema irá tentar obtê-lo da stream do repositorio |
638 | //Nesse caso o sistema irá tentar obtê-lo da stream do repositorio |
639 | if(course.getStudiesPlans() == null || course.getStudiesPlans().size() == 0) |
639 | if(course.getStudiesPlans() == null || course.getStudiesPlans().size() == 0) |
640 | { |
640 | { |
641 | logger.info("status JSON NOT EXIST FOR STUDIES PLAN IN THIS COURSE, will try generate from studies plan OLD Stream"); |
641 | logger.info("status JSON NOT EXIST FOR STUDIES PLAN IN THIS COURSE, will try generate from studies plan OLD Stream"); |
642 | UserSession userSession = DomainObjectFactory.createUserSessionImpl(); |
642 | UserSession userSession = DomainObjectFactory.createUserSessionImpl(); |
643 | userSession.setUser(DaoFactory.getUserDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(1))); |
643 | userSession.setUser(DaoFactory.getUserDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(1))); |
644 | new CoursesService().generateXmlJaxbStudiesPlanVersionFromRepositoryOldPlanStream(userSession, course, false, null); |
644 | new CoursesService().generateXmlJaxbStudiesPlanVersionFromRepositoryOldPlanStream(userSession, course, false, null); |
645 | } |
645 | } |
646 | 646 | ||
647 | if(course.getStudiesPlans() != null ) |
647 | if(course.getStudiesPlans() != null ) |
648 | { |
648 | { |
649 | CourseStudiesPlan studiesPlan = course.getStudiesPlans().iterator().next(); |
649 | CourseStudiesPlan studiesPlan = course.getStudiesPlans().iterator().next(); |
650 | JSONObject studiesPlanObj; |
650 | JSONObject studiesPlanObj; |
651 | if(studiesPlan.getJson() != null) |
651 | if(studiesPlan.getJson() != null) |
652 | { |
652 | { |
653 | CursoImpl c = CursoImpl.loadFromJson(studiesPlan.getJson()); |
653 | CursoImpl c = CursoImpl.loadFromJson(studiesPlan.getJson()); |
654 | autoFillTotalHorasContacto(c); |
654 | autoFillTotalHorasContacto(c); |
655 | studiesPlanObj = c.toJsonObjectJsonApiWS(); |
655 | studiesPlanObj = c.toJsonObjectJsonApiWS(); |
656 | studiesPlanObj.put("version",studiesPlan.getVersion()); |
656 | studiesPlanObj.put("version",studiesPlan.getVersion()); |
657 | coursesResponse.put("courseStudiesPlan",studiesPlanObj); |
657 | coursesResponse.put("courseStudiesPlan",studiesPlanObj); |
658 | } |
658 | } |
659 | else |
659 | else |
660 | { |
660 | { |
661 | studiesPlanObj = new JSONObject(); |
661 | studiesPlanObj = new JSONObject(); |
662 | studiesPlanObj.put("fault","Zero contents for this version"); |
662 | studiesPlanObj.put("fault","Zero contents for this version"); |
663 | studiesPlanObj.put("version",studiesPlan.getVersion()); |
663 | studiesPlanObj.put("version",studiesPlan.getVersion()); |
664 | coursesResponse.put("courseStudiesPlan",studiesPlanObj); |
664 | coursesResponse.put("courseStudiesPlan",studiesPlanObj); |
665 | } |
665 | } |
666 | coursesResponse.put("courseStudiesPlan",studiesPlanObj); |
666 | coursesResponse.put("courseStudiesPlan",studiesPlanObj); |
667 | 667 | ||
668 | } |
668 | } |
669 | else |
669 | else |
670 | { |
670 | { |
671 | coursesResponse.put("status","JSON NOT EXIST FOR STUDIES PLAN IN THIS COURSE"); |
671 | coursesResponse.put("status","JSON NOT EXIST FOR STUDIES PLAN IN THIS COURSE"); |
672 | } |
672 | } |
673 | } |
673 | } |
674 | else |
674 | else |
675 | { |
675 | { |
676 | coursesResponse.put("status","JSON NOT EXIST FOR COURSE, PLEASE OPEN AND SAVE COURSE IN ADMINISTRATION"); |
676 | coursesResponse.put("status","JSON NOT EXIST FOR COURSE, PLEASE OPEN AND SAVE COURSE IN ADMINISTRATION"); |
677 | } |
677 | } |
678 | return coursesResponse; |
678 | return coursesResponse; |
679 | } |
679 | } |
680 | 680 | ||
681 | /** |
681 | /** |
682 | * @SERVICE@ |
682 | * @SERVICE@ |
683 | * |
683 | * |
684 | * @param code |
684 | * @param code |
685 | * @return |
685 | * @return |
686 | * @throws JSONException |
686 | * @throws JSONException |
687 | */ |
687 | */ |
688 | public 1.5.0/docs/api/java/lang/String.html">String getCourseStudiesPlanXml(1.5.0/docs/api/java/lang/String.html">String code,1.5.0/docs/api/java/lang/String.html">String renew) throws JSONException { |
688 | public 1.5.0/docs/api/java/lang/String.html">String getCourseStudiesPlanXml(1.5.0/docs/api/java/lang/String.html">String code,1.5.0/docs/api/java/lang/String.html">String renew) throws JSONException { |
689 | 689 | ||
690 | Course course = DaoFactory.getCourseDaoImpl().findCourseByCode(code); |
690 | Course course = DaoFactory.getCourseDaoImpl().findCourseByCode(code); |
691 | 691 | ||
692 | if(renew != null || course.getStudiesPlans() == null || course.getStudiesPlans().size() == 0) |
692 | if(renew != null || course.getStudiesPlans() == null || course.getStudiesPlans().size() == 0) |
693 | { |
693 | { |
694 | logger.info("status JSON NOT EXIST FOR STUDIES PLAN IN THIS COURSE, will generate"); |
694 | logger.info("status JSON NOT EXIST FOR STUDIES PLAN IN THIS COURSE, will generate"); |
695 | UserSession userSession = DomainObjectFactory.createUserSessionImpl(); |
695 | UserSession userSession = DomainObjectFactory.createUserSessionImpl(); |
696 | userSession.setUser(DaoFactory.getUserDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(1))); |
696 | userSession.setUser(DaoFactory.getUserDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(1))); |
697 | try { |
697 | try { |
698 | generateXmlJaxbStudiesPlanVersionFromRepositoryOldPlanStream(userSession, course, false, null); |
698 | generateXmlJaxbStudiesPlanVersionFromRepositoryOldPlanStream(userSession, course, false, null); |
699 | } catch (JAXBException e) { |
699 | } catch (JAXBException e) { |
700 | logger.error(e,e); |
700 | logger.error(e,e); |
701 | return "<error>" + e.toString() + ". see log for details</error>"; |
701 | return "<error>" + e.toString() + ". see log for details</error>"; |
702 | } |
702 | } |
703 | } |
703 | } |
704 | 704 | ||
705 | if(course.getStudiesPlans() != null && course.getStudiesPlans().size() > 0) |
705 | if(course.getStudiesPlans() != null && course.getStudiesPlans().size() > 0) |
706 | { |
706 | { |
707 | return course.getStudiesPlans().iterator().next().getXml(); |
707 | return course.getStudiesPlans().iterator().next().getXml(); |
708 | } |
708 | } |
709 | return "<error>Does not exixt</error>"; |
709 | return "<error>Does not exixt</error>"; |
710 | 710 | ||
711 | } |
711 | } |
712 | 712 | ||
713 | 713 | ||
714 | /** |
714 | /** |
715 | * @SERVICE@ |
715 | * @SERVICE@ |
716 | * |
716 | * |
717 | * @param systemUrl |
717 | * @param systemUrl |
718 | * @param setActive |
718 | * @param setActive |
719 | * @return |
719 | * @return |
720 | * @throws IOException |
720 | * @throws IOException |
721 | * @throws JSONException |
721 | * @throws JSONException |
722 | * @throws JAXBException |
722 | * @throws JAXBException |
723 | */ |
723 | */ |
724 | 724 | ||
725 | public 1.5.0/docs/api/java/lang/String.html">String sincronizeCoursesStudiesPlans(1.5.0/docs/api/java/lang/String.html">String systemUrl,boolean setActive,UserSession sess) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException, JAXBException { |
725 | public 1.5.0/docs/api/java/lang/String.html">String sincronizeCoursesStudiesPlans(1.5.0/docs/api/java/lang/String.html">String systemUrl,boolean setActive,UserSession sess) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException, JAXBException { |
726 | 726 | ||
727 | 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder log = new 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder(); |
727 | 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder log = new 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder(); |
728 | 1.5.0/docs/api/java/net/URL.html">URL url = new 1.5.0/docs/api/java/net/URL.html">URL(systemUrl + "/wsjson/api?service=listCourses"); |
728 | 1.5.0/docs/api/java/net/URL.html">URL url = new 1.5.0/docs/api/java/net/URL.html">URL(systemUrl + "/wsjson/api?service=listCourses"); |
729 | 5+0%2Fdocs%2Fapi+InputStream">InputStream is = url.openStream(); |
729 | 5+0%2Fdocs%2Fapi+InputStream">InputStream is = url.openStream(); |
730 | 1.5.0/docs/api/java/lang/String.html">String str = StreamsUtils.readString(is); |
730 | 1.5.0/docs/api/java/lang/String.html">String str = StreamsUtils.readString(is); |
731 | JSONObject obj = new JSONObject(str); |
731 | JSONObject obj = new JSONObject(str); |
732 | JSONArray courses = obj.getJSONArray("courses"); |
732 | JSONArray courses = obj.getJSONArray("courses"); |
733 | for(int i = 0; i < courses.length();i++) |
733 | for(int i = 0; i < courses.length();i++) |
734 | { |
734 | { |
735 | 1.5.0/docs/api/java/lang/String.html">String code = ""; |
735 | 1.5.0/docs/api/java/lang/String.html">String code = ""; |
736 | try{ |
736 | try{ |
737 | JSONObject course = courses.getJSONObject(i); |
737 | JSONObject course = courses.getJSONObject(i); |
738 | code = course.getString("code"); |
738 | code = course.getString("code"); |
739 | Course c = DaoFactory.getCourseDaoImpl().findCourseByCode(code); |
739 | Course c = DaoFactory.getCourseDaoImpl().findCourseByCode(code); |
740 | if(c == null) |
740 | if(c == null) |
741 | { |
741 | { |
742 | 1.5.0/docs/api/java/lang/String.html">String msg = "SKIPING - Course " + code + " " + course.getString("name") + " does not exist in this system"; |
742 | 1.5.0/docs/api/java/lang/String.html">String msg = "SKIPING - Course " + code + " " + course.getString("name") + " does not exist in this system"; |
743 | log.append("<info>" + msg+"</info>"); |
743 | log.append("<info>" + msg+"</info>"); |
744 | logger.info(msg); |
744 | logger.info(msg); |
745 | } |
745 | } |
746 | else |
746 | else |
747 | { |
747 | { |
748 | 1.5.0/docs/api/java/lang/String.html">String msg = "UPDATING - Course " + code + " " + course.getString("name") + " exist in this system"; |
748 | 1.5.0/docs/api/java/lang/String.html">String msg = "UPDATING - Course " + code + " " + course.getString("name") + " exist in this system"; |
749 | log.append("<info>" + msg+"</info>"); |
749 | log.append("<info>" + msg+"</info>"); |
750 | logger.info(msg); |
750 | logger.info(msg); |
751 | 751 | ||
752 | //#############UPDATING Course Comission Members |
752 | //#############UPDATING Course Comission Members |
753 | updateCourseComissionMembersAndCourseInfo(systemUrl, code, c); |
753 | updateCourseComissionMembersAndCourseInfo(systemUrl, code, c); |
754 | 754 | ||
755 | //#############UPDATING STUDIES PLAN |
755 | //#############UPDATING STUDIES PLAN |
756 | updateStudiesPlanFromRemoteSystem(systemUrl, setActive, log, course, code, c); |
756 | updateStudiesPlanFromRemoteSystem(systemUrl, setActive, log, course, code, c); |
757 | 757 | ||
758 | 758 | ||
759 | } |
759 | } |
760 | } |
760 | } |
761 | catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
761 | catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
762 | { |
762 | { |
763 | logger.error("UPDATE COURSE: " + i + " code: " + code + " FAILED"); |
763 | logger.error("UPDATE COURSE: " + i + " code: " + code + " FAILED"); |
764 | logger.error(e,e); |
764 | logger.error(e,e); |
765 | } |
765 | } |
766 | } |
766 | } |
767 | return log.toString(); |
767 | return log.toString(); |
768 | 768 | ||
769 | } |
769 | } |
770 | 770 | ||
771 | private void updateStudiesPlanFromRemoteSystem(1.5.0/docs/api/java/lang/String.html">String systemUrl, boolean setActive, 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder log, JSONObject course, 1.5.0/docs/api/java/lang/String.html">String code, Course c) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException, JAXBException { |
771 | private void updateStudiesPlanFromRemoteSystem(1.5.0/docs/api/java/lang/String.html">String systemUrl, boolean setActive, 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder log, JSONObject course, 1.5.0/docs/api/java/lang/String.html">String code, Course c) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException, JAXBException { |
772 | 1.5.0/docs/api/java/lang/String.html">String msg; |
772 | 1.5.0/docs/api/java/lang/String.html">String msg; |
773 | 5+0%2Fdocs%2Fapi+InputStream">InputStream stream = new 1.5.0/docs/api/java/net/URL.html">URL(systemUrl + "/wsjson/api?service=getStudiesPlanXml&code=" + code + "&renew=true").openStream(); |
773 | 5+0%2Fdocs%2Fapi+InputStream">InputStream stream = new 1.5.0/docs/api/java/net/URL.html">URL(systemUrl + "/wsjson/api?service=getStudiesPlanXml&code=" + code + "&renew=true").openStream(); |
774 | 1.5.0/docs/api/java/lang/String.html">String studiesPlan = StreamsUtils.readString(stream); |
774 | 1.5.0/docs/api/java/lang/String.html">String studiesPlan = StreamsUtils.readString(stream); |
775 | int len = studiesPlan.length(); |
775 | int len = studiesPlan.length(); |
776 | if(studiesPlan == null || studiesPlan.trim().length() == 0 || studiesPlan.contains("<error>")) |
776 | if(studiesPlan == null || studiesPlan.trim().length() == 0 || studiesPlan.contains("<error>")) |
777 | { |
777 | { |
778 | msg = "Course " + code + " " + course.getString("name") + " dont has studies plan"; |
778 | msg = "Course " + code + " " + course.getString("name") + " dont has studies plan"; |
779 | log.append("<warn>" + msg+"</warn>"); |
779 | log.append("<warn>" + msg+"</warn>"); |
780 | logger.warn(msg); |
780 | logger.warn(msg); |
781 | } |
781 | } |
782 | else |
782 | else |
783 | { |
783 | { |
784 | msg = "Found studies plan for " + code + " " + course.getString("name") + " will update "; |
784 | msg = "Found studies plan for " + code + " " + course.getString("name") + " will update "; |
785 | log.append("<info>" + msg+"</info>"); |
785 | log.append("<info>" + msg+"</info>"); |
786 | logger.info(msg); |
786 | logger.info(msg); |
787 | if(setActive) |
787 | if(setActive) |
788 | { |
788 | { |
789 | msg = "Setting course to active"; |
789 | msg = "Setting course to active"; |
790 | log.append("<info>" + msg+"</info>"); |
790 | log.append("<info>" + msg+"</info>"); |
791 | logger.info(msg); |
791 | logger.info(msg); |
792 | c.setStatus(true); |
792 | c.setStatus(true); |
793 | } |
793 | } |
794 | //System.out.println(studiesPlan); |
794 | //System.out.println(studiesPlan); |
795 | msg = "GENERATING COURSE JSON ...."; |
795 | msg = "GENERATING COURSE JSON ...."; |
796 | log.append("<info>" + msg+"</info>"); |
796 | log.append("<info>" + msg+"</info>"); |
797 | logger.info(msg); |
797 | logger.info(msg); |
798 | new CoursesService().generateCourseJson(c); |
798 | new CoursesService().generateCourseJson(c); |
799 | 799 | ||
800 | msg="GENERATING COURSE STUDIES PLAN JSON ...."; |
800 | msg="GENERATING COURSE STUDIES PLAN JSON ...."; |
801 | log.append("<info>" + msg+"</info>"); |
801 | log.append("<info>" + msg+"</info>"); |
802 | logger.info(msg); |
802 | logger.info(msg); |
803 | stream.close(); |
803 | stream.close(); |
804 | stream = new 1.5.0/docs/api/java/net/URL.html">URL(systemUrl + "/wsjson/api?service=getStudiesPlanXml&code=" + code).openStream(); |
804 | stream = new 1.5.0/docs/api/java/net/URL.html">URL(systemUrl + "/wsjson/api?service=getStudiesPlanXml&code=" + code).openStream(); |
805 | UserSession userSession = DomainObjectFactory.createUserSessionImpl(); |
805 | UserSession userSession = DomainObjectFactory.createUserSessionImpl(); |
806 | userSession.setUser(DaoFactory.getUserDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(1))); |
806 | userSession.setUser(DaoFactory.getUserDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(1))); |
807 | new CoursesService().uploadStudiesPlan(stream, "curso_" + code + ".xml", len,"appication/xml", userSession,c,true,systemUrl); |
807 | new CoursesService().uploadStudiesPlan(stream, "curso_" + code + ".xml", len,"appication/xml", userSession,c,true,systemUrl); |
808 | } |
808 | } |
809 | } |
809 | } |
810 | 810 | ||
811 | 811 | ||
812 | /** |
812 | /** |
813 | * Update courseComission Members |
813 | * Update courseComission Members |
814 | * @param systemUrl |
814 | * @param systemUrl |
815 | * @param code |
815 | * @param code |
816 | * @param c |
816 | * @param c |
817 | * @throws IOException |
817 | * @throws IOException |
818 | * @throws JSONException |
818 | * @throws JSONException |
819 | */ |
819 | */ |
820 | private void updateCourseComissionMembersAndCourseInfo(1.5.0/docs/api/java/lang/String.html">String systemUrl, 1.5.0/docs/api/java/lang/String.html">String code, Course c) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException |
820 | private void updateCourseComissionMembersAndCourseInfo(1.5.0/docs/api/java/lang/String.html">String systemUrl, 1.5.0/docs/api/java/lang/String.html">String code, Course c) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException |
821 | { |
821 | { |
822 | 822 | ||
823 | 1.5.0/docs/api/java/net/URL.html">URL urlCourseDetails = new 1.5.0/docs/api/java/net/URL.html">URL(systemUrl + "/wsjson/api?service=getCourse&code=" + code); |
823 | 1.5.0/docs/api/java/net/URL.html">URL urlCourseDetails = new 1.5.0/docs/api/java/net/URL.html">URL(systemUrl + "/wsjson/api?service=getCourse&code=" + code); |
824 | 5+0%2Fdocs%2Fapi+InputStream">InputStream isCourseDetails = urlCourseDetails.openStream(); |
824 | 5+0%2Fdocs%2Fapi+InputStream">InputStream isCourseDetails = urlCourseDetails.openStream(); |
825 | 1.5.0/docs/api/java/lang/String.html">String strCourseDetails = StreamsUtils.readString(isCourseDetails); |
825 | 1.5.0/docs/api/java/lang/String.html">String strCourseDetails = StreamsUtils.readString(isCourseDetails); |
826 | JSONObject objCourseDetails = new JSONObject(strCourseDetails); |
826 | JSONObject objCourseDetails = new JSONObject(strCourseDetails); |
827 | 827 | ||
828 | //DEPARTMENT |
828 | //DEPARTMENT |
829 | JSONObject department = objCourseDetails.getJSONObject("courseInfo").getJSONObject("department"); |
829 | JSONObject department = objCourseDetails.getJSONObject("courseInfo").getJSONObject("department"); |
830 | if(department != null) |
830 | if(department != null) |
831 | { |
831 | { |
832 | 1.5.0/docs/api/java/lang/String.html">String sigla = department.getString("sigla"); |
832 | 1.5.0/docs/api/java/lang/String.html">String sigla = department.getString("sigla"); |
833 | if(sigla != null) |
833 | if(sigla != null) |
834 | { |
834 | { |
835 | CourseDepartment department1 = DaoFactory.getCourseDepartmentDaoImpl().findBySigla(sigla); |
835 | CourseDepartment department1 = DaoFactory.getCourseDepartmentDaoImpl().findBySigla(sigla); |
836 | if(department1 != null) |
836 | if(department1 != null) |
837 | { |
837 | { |
838 | c.setDepartment(department1); |
838 | c.setDepartment(department1); |
839 | } |
839 | } |
840 | } |
840 | } |
841 | } |
841 | } |
842 | 842 | ||
843 | 843 | ||
844 | 1.5.0/docs/api/java/lang/String.html">String validationRole = objCourseDetails.getJSONObject("courseInfo").getString("validationRole"); |
844 | 1.5.0/docs/api/java/lang/String.html">String validationRole = objCourseDetails.getJSONObject("courseInfo").getString("validationRole"); |
845 | 845 | ||
846 | 846 | ||
847 | 847 | ||
848 | 848 | ||
849 | if(validationRole == null) |
849 | if(validationRole == null) |
850 | { |
850 | { |
851 | logger.info("validationRole is not defined"); |
851 | logger.info("validationRole is not defined"); |
852 | } |
852 | } |
853 | else |
853 | else |
854 | { |
854 | { |
855 | logger.info("found validationRole: " + validationRole); |
855 | logger.info("found validationRole: " + validationRole); |
856 | c.setValidationRole(validationRole); |
856 | c.setValidationRole(validationRole); |
857 | 857 | ||
858 | JSONObject coordinator = objCourseDetails.getJSONObject("courseInfo").getJSONObject("coordinator"); |
858 | JSONObject coordinator = objCourseDetails.getJSONObject("courseInfo").getJSONObject("coordinator"); |
859 | JSONArray courseComission = objCourseDetails.getJSONObject("courseInfo").getJSONArray("courseComission"); |
859 | JSONArray courseComission = objCourseDetails.getJSONObject("courseInfo").getJSONArray("courseComission"); |
860 | 860 | ||
861 | Teacher coordinatorPersistent = findPersonFromCourseDetails(coordinator); |
861 | Teacher coordinatorPersistent = findPersonFromCourseDetails(coordinator); |
862 | if(coordinatorPersistent == null) |
862 | if(coordinatorPersistent == null) |
863 | { |
863 | { |
864 | logger.warn("Coordinator does not exist in this system "); |
864 | logger.warn("Coordinator does not exist in this system "); |
865 | } |
865 | } |
866 | else |
866 | else |
867 | { |
867 | { |
868 | c.setCoordinator(coordinatorPersistent); |
868 | c.setCoordinator(coordinatorPersistent); |
869 | } |
869 | } |
870 | 870 | ||
871 | List<User> users = DaoFactory.getUserDaoImpl().loadRoleUsers(validationRole); |
871 | List<User> users = DaoFactory.getUserDaoImpl().loadRoleUsers(validationRole); |
872 | logger.info("Encontrados " + users.size() + " docentes com o papel de comissao " + validationRole + " vai remover"); |
872 | logger.info("Encontrados " + users.size() + " docentes com o papel de comissao " + validationRole + " vai remover"); |
873 | for(User u: users) |
873 | for(User u: users) |
874 | { |
874 | { |
875 | logger.info("Removendo role a " + u.getName()); |
875 | logger.info("Removendo role a " + u.getName()); |
876 | u.removeRole(validationRole); |
876 | u.removeRole(validationRole); |
877 | } |
877 | } |
878 | 878 | ||
879 | for(int j = 0 ; j < courseComission.length(); j++) |
879 | for(int j = 0 ; j < courseComission.length(); j++) |
880 | { |
880 | { |
881 | JSONObject memberComission = courseComission.getJSONObject(j); |
881 | JSONObject memberComission = courseComission.getJSONObject(j); |
882 | Teacher memberPersistent = findPersonFromCourseDetails(memberComission); |
882 | Teacher memberPersistent = findPersonFromCourseDetails(memberComission); |
883 | if(memberPersistent == null) |
883 | if(memberPersistent == null) |
884 | { |
884 | { |
885 | logger.info("Member does not exist in this system "); |
885 | logger.info("Member does not exist in this system "); |
886 | } |
886 | } |
887 | else |
887 | else |
888 | { |
888 | { |
889 | logger.info("Adding role of course comission member"); |
889 | logger.info("Adding role of course comission member"); |
890 | if(!memberPersistent.hasRole(validationRole)) |
890 | if(!memberPersistent.hasRole(validationRole)) |
891 | { |
891 | { |
892 | memberPersistent.addRole(validationRole); |
892 | memberPersistent.addRole(validationRole); |
893 | } |
893 | } |
894 | } |
894 | } |
895 | } |
895 | } |
896 | } |
896 | } |
897 | } |
897 | } |
898 | 898 | ||
899 | private Teacher findPersonFromCourseDetails(JSONObject coordinator) { |
899 | private Teacher findPersonFromCourseDetails(JSONObject coordinator) { |
900 | int code; |
900 | int code; |
901 | try { |
901 | try { |
902 | if(coordinator.has("sigesCode")) |
902 | if(coordinator.has("sigesCode")) |
903 | { |
903 | { |
904 | code = coordinator.getInt("sigesCode"); |
904 | code = coordinator.getInt("sigesCode"); |
905 | } |
905 | } |
906 | else |
906 | else |
907 | { |
907 | { |
908 | logger.warn("there is no sigesCode for this person " + coordinator.toString()); |
908 | logger.warn("there is no sigesCode for this person " + coordinator.toString()); |
909 | return null; |
909 | return null; |
910 | } |
910 | } |
911 | } catch (JSONException e){ |
911 | } catch (JSONException e){ |
912 | return null; |
912 | return null; |
913 | } catch (1.5.0/docs/api/java/lang/NumberFormatException.html">NumberFormatException e){ |
913 | } catch (1.5.0/docs/api/java/lang/NumberFormatException.html">NumberFormatException e){ |
914 | return null; |
914 | return null; |
915 | } |
915 | } |
916 | return DaoFactory.getTeacherDaoImpl().loadBySigesCode(code); |
916 | return DaoFactory.getTeacherDaoImpl().loadBySigesCode(code); |
917 | } |
917 | } |
918 | 918 | ||
919 | 919 | ||
920 | 920 | ||
921 | /* |
921 | /* |
922 | * Studies Plans Administration Services |
922 | * Studies Plans Administration Services |
923 | * |
923 | * |
924 | */ |
924 | */ |
925 | public void addNewStudiesPlan(long courseId,CourseStudiesPlan studiesPlan,UserSession session) |
925 | public void addNewStudiesPlan(long courseId,CourseStudiesPlan studiesPlan,UserSession session) |
926 | { |
926 | { |
927 | Course c = DaoFactory.getCourseDaoImpl().load(courseId); |
927 | Course c = DaoFactory.getCourseDaoImpl().load(courseId); |
928 | studiesPlan.setCourse(c); |
928 | studiesPlan.setCourse(c); |
929 | c.getStudiesPlans().add(studiesPlan); |
929 | c.getStudiesPlans().add(studiesPlan); |
930 | DaoFactory.getCourseStudiesPlanDaoImpl().save(studiesPlan); |
930 | DaoFactory.getCourseStudiesPlanDaoImpl().save(studiesPlan); |
931 | } |
931 | } |
932 | 932 | ||
933 | public CourseStudiesPlanImpl cloneVersionFrom(long sourcePlanId, long targetPlanId, long courseId, UserSession session) |
933 | public CourseStudiesPlanImpl cloneVersionFrom(long sourcePlanId, long targetPlanId, long courseId, UserSession session) |
934 | { |
934 | { |
935 | Course course = DaoFactory.getCourseDaoImpl().load(courseId); |
935 | Course course = DaoFactory.getCourseDaoImpl().load(courseId); |
936 | CourseStudiesPlan source = null; |
936 | CourseStudiesPlan source = null; |
937 | CourseStudiesPlan target = null; |
937 | CourseStudiesPlan target = null; |
938 | for(CourseStudiesPlan plan: course.getStudiesPlans()) |
938 | for(CourseStudiesPlan plan: course.getStudiesPlans()) |
939 | { |
939 | { |
940 | if(plan.getId() == sourcePlanId) |
940 | if(plan.getId() == sourcePlanId) |
941 | source = plan; |
941 | source = plan; |
942 | else if(plan.getId() == targetPlanId) |
942 | else if(plan.getId() == targetPlanId) |
943 | target = plan; |
943 | target = plan; |
944 | } |
944 | } |
945 | target.setXml(source.getXml()); |
945 | target.setXml(source.getXml()); |
946 | target.setJson(source.getJson()); |
946 | target.setJson(source.getJson()); |
947 | return (CourseStudiesPlanImpl) DaoFactory.getCourseStudiesPlanDaoImpl().narrow(target); |
947 | return (CourseStudiesPlanImpl) DaoFactory.getCourseStudiesPlanDaoImpl().narrow(target); |
948 | } |
948 | } |
949 | 949 | ||
950 | public Curso loadCursoPlanoFromXml(1.5.0/docs/api/java/lang/String.html">String xml) |
950 | public Curso loadCursoPlanoFromXml(1.5.0/docs/api/java/lang/String.html">String xml) |
951 | { |
951 | { |
952 | try { |
952 | try { |
953 | if(xml != null) |
953 | if(xml != null) |
954 | { |
954 | { |
955 | JAXBContext jc = JAXBContext.newInstance(Curso.class); |
955 | JAXBContext jc = JAXBContext.newInstance(Curso.class); |
956 | Unmarshaller unmarshaller = jc.createUnmarshaller(); |
956 | Unmarshaller unmarshaller = jc.createUnmarshaller(); |
957 | Curso curso = (Curso) unmarshaller.unmarshal(new 1.5.0/docs/api/java/io/StringReader.html">StringReader(xml)); |
957 | Curso curso = (Curso) unmarshaller.unmarshal(new 1.5.0/docs/api/java/io/StringReader.html">StringReader(xml)); |
958 | return curso; |
958 | return curso; |
959 | } |
959 | } |
960 | return null; |
960 | return null; |
961 | } catch (JAXBException e) { |
961 | } catch (JAXBException e) { |
962 | logger.error(e,e); |
962 | logger.error(e,e); |
963 | return null; |
963 | return null; |
964 | } |
964 | } |
965 | } |
965 | } |
966 | 966 | ||
967 | /** |
967 | /** |
968 | * Persist the edited studies plan |
968 | * Persist the edited studies plan |
969 | * Updates studiesPlanVersion |
969 | * Updates studiesPlanVersion |
970 | * Updates studiesPlanVersionDescription |
970 | * Updates studiesPlanVersionDescription |
971 | * Updates PlanoEstudos XML and JSON |
971 | * Updates PlanoEstudos XML and JSON |
972 | * TODO REVER |
972 | * TODO REVER |
973 | * @param courseId |
973 | * @param courseId |
974 | * @param coursePlanId |
974 | * @param coursePlanId |
975 | * @param planoEditado |
975 | * @param planoEditado |
976 | * @param courseStudiesPlanEditado |
976 | * @param courseStudiesPlanEditado |
977 | * @return |
977 | * @return |
978 | */ |
978 | */ |
979 | public Course savePlanoEstudosEditado(long courseId, long coursePlanId, Curso planoEditado, CourseStudiesPlan courseStudiesPlanEditado,UserSession session) |
979 | public Course savePlanoEstudosEditado(long courseId, long coursePlanId, Curso planoEditado, CourseStudiesPlan courseStudiesPlanEditado,UserSession session) |
980 | { |
980 | { |
981 | try { |
981 | try { |
982 | Course course = DaoFactory.getCourseDaoImpl().load(courseId); |
982 | Course course = DaoFactory.getCourseDaoImpl().load(courseId); |
983 | 983 | ||
984 | for(CourseStudiesPlan courseStudiesPlanPersistente: course.getStudiesPlans()) |
984 | for(CourseStudiesPlan courseStudiesPlanPersistente: course.getStudiesPlans()) |
985 | { |
985 | { |
986 | if(courseStudiesPlanPersistente.getId() == coursePlanId) |
986 | if(courseStudiesPlanPersistente.getId() == coursePlanId) |
987 | { |
987 | { |
988 | courseStudiesPlanPersistente.setVersion(courseStudiesPlanEditado.getVersion()); |
988 | courseStudiesPlanPersistente.setVersion(courseStudiesPlanEditado.getVersion()); |
989 | courseStudiesPlanPersistente.setVersionDescription(courseStudiesPlanEditado.getVersionDescription()); |
989 | courseStudiesPlanPersistente.setVersionDescription(courseStudiesPlanEditado.getVersionDescription()); |
990 | 990 | ||
991 | //REMOVED UNIDADES TO REMOVE |
991 | //REMOVED UNIDADES TO REMOVE |
992 | for(Curso.Semestre semestre:planoEditado.getSemestre()) |
992 | for(Curso.Semestre semestre:planoEditado.getSemestre()) |
993 | { |
993 | { |
994 | Iterator<UnidadeType> uIter = semestre.getUnidade().iterator(); |
994 | Iterator<UnidadeType> uIter = semestre.getUnidade().iterator(); |
995 | while(uIter.hasNext()) |
995 | while(uIter.hasNext()) |
996 | { |
996 | { |
997 | UnidadeType unidade = uIter.next(); |
997 | UnidadeType unidade = uIter.next(); |
998 | if(unidade.getRemoved() != null && unidade.getRemoved().equals("true")) |
998 | if(unidade.getRemoved() != null && unidade.getRemoved().equals("true")) |
999 | uIter.remove(); |
999 | uIter.remove(); |
1000 | } |
1000 | } |
1001 | for(Curso.Semestre.Perfil perfil: semestre.getPerfil()) |
1001 | for(Curso.Semestre.Perfil perfil: semestre.getPerfil()) |
1002 | { |
1002 | { |
1003 | Iterator<UnidadeType> uIter2 = perfil.getUnidade().iterator(); |
1003 | Iterator<UnidadeType> uIter2 = perfil.getUnidade().iterator(); |
1004 | while(uIter2.hasNext()) |
1004 | while(uIter2.hasNext()) |
1005 | { |
1005 | { |
1006 | UnidadeType unidade = uIter2.next(); |
1006 | UnidadeType unidade = uIter2.next(); |
1007 | if(unidade.getRemoved() != null && unidade.getRemoved().equals("true")) |
1007 | if(unidade.getRemoved() != null && unidade.getRemoved().equals("true")) |
1008 | uIter2.remove(); |
1008 | uIter2.remove(); |
1009 | } |
1009 | } |
1010 | } |
1010 | } |
1011 | } |
1011 | } |
1012 | //Garante-se mas depois não vai para o JSON |
1012 | //Garante-se mas depois não vai para o JSON |
1013 | planoEditado.setSiges(course.getCode());//GARANTIR QUE O CODIGO SIGEST ESTA CORRECTO |
1013 | planoEditado.setSiges(course.getCode());//GARANTIR QUE O CODIGO SIGEST ESTA CORRECTO |
1014 | planoEditado.setNome(course.getName()); |
1014 | planoEditado.setNome(course.getName()); |
1015 | planoEditado.setDep(course.getArea()); |
1015 | planoEditado.setDep(course.getArea()); |
1016 | 1016 | ||
1017 | /** |
1017 | /** |
1018 | * Calcula automaticamente as horas de contacto totais |
1018 | * Calcula automaticamente as horas de contacto totais |
1019 | */ |
1019 | */ |
1020 | autoFillTotalHorasContacto(planoEditado); |
1020 | autoFillTotalHorasContacto(planoEditado); |
1021 | 1021 | ||
1022 | //planoEditado.setDepDesc(""); |
1022 | //planoEditado.setDepDesc(""); |
1023 | //planoEditado.setDepDescEn(""); |
1023 | //planoEditado.setDepDescEn(""); |
1024 | //planoEditado.setDepDescEs(""); |
1024 | //planoEditado.setDepDescEs(""); |
1025 | //planoEditado.setDepDescFr(""); |
1025 | //planoEditado.setDepDescFr(""); |
1026 | JAXBContext jc = JAXBContext.newInstance(Curso.class); |
1026 | JAXBContext jc = JAXBContext.newInstance(Curso.class); |
1027 | Marshaller marshaller = jc.createMarshaller(); |
1027 | Marshaller marshaller = jc.createMarshaller(); |
1028 | marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); |
1028 | marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); |
1029 | 1.5.0/docs/api/java/io/StringWriter.html">StringWriter xml = new 1.5.0/docs/api/java/io/StringWriter.html">StringWriter(); |
1029 | 1.5.0/docs/api/java/io/StringWriter.html">StringWriter xml = new 1.5.0/docs/api/java/io/StringWriter.html">StringWriter(); |
1030 | marshaller.marshal(planoEditado,xml); |
1030 | marshaller.marshal(planoEditado,xml); |
1031 | 1031 | ||
1032 | courseStudiesPlanPersistente.setXml(xml.toString()); |
1032 | courseStudiesPlanPersistente.setXml(xml.toString()); |
1033 | 1.5.0/docs/api/java/lang/String.html">String json = CursoImpl.getGensonPlanoEstudosParaApiJsonWS().serialize(planoEditado); |
1033 | 1.5.0/docs/api/java/lang/String.html">String json = CursoImpl.getGensonPlanoEstudosParaApiJsonWS().serialize(planoEditado); |
1034 | //SETTING JSON in COURSE STUDIES PLAN |
1034 | //SETTING JSON in COURSE STUDIES PLAN |
1035 | courseStudiesPlanPersistente.setJson(json); |
1035 | courseStudiesPlanPersistente.setJson(json); |
1036 | break; |
1036 | break; |
1037 | } |
1037 | } |
1038 | } |
1038 | } |
1039 | return course; |
1039 | return course; |
1040 | } catch (JAXBException e) { |
1040 | } catch (JAXBException e) { |
1041 | logger.error(e,e); |
1041 | logger.error(e,e); |
1042 | return null; |
1042 | return null; |
1043 | } |
1043 | } |
1044 | } |
1044 | } |
1045 | 1045 | ||
1046 | private void autoFillTotalHorasContacto(Curso planoEditado) { |
1046 | private void autoFillTotalHorasContacto(Curso planoEditado) { |
1047 | if(planoEditado.getSemestre() != null) |
1047 | if(planoEditado.getSemestre() != null) |
1048 | { |
1048 | { |
1049 | for(Curso.Semestre s : planoEditado.getSemestre()) |
1049 | for(Curso.Semestre s : planoEditado.getSemestre()) |
1050 | { |
1050 | { |
1051 | if(s.getUnidade() != null) |
1051 | if(s.getUnidade() != null) |
1052 | { |
1052 | { |
1053 | for(UnidadeType u : s.getUnidade()) |
1053 | for(UnidadeType u : s.getUnidade()) |
1054 | { |
1054 | { |
1055 | u.setTotalHorasContacto(UnidadeImpl.calculateTotalHorasContacto(u.getHorasContacto())); |
1055 | u.setTotalHorasContacto(UnidadeImpl.calculateTotalHorasContacto(u.getHorasContacto())); |
1056 | } |
1056 | } |
1057 | } |
1057 | } |
1058 | if(s.getPerfil() != null) |
1058 | if(s.getPerfil() != null) |
1059 | { |
1059 | { |
1060 | for(Curso.Semestre.Perfil p : s.getPerfil()) |
1060 | for(Curso.Semestre.Perfil p : s.getPerfil()) |
1061 | { |
1061 | { |
1062 | if(p.getUnidade() != null) |
1062 | if(p.getUnidade() != null) |
1063 | { |
1063 | { |
1064 | for(UnidadeType u : p.getUnidade()) |
1064 | for(UnidadeType u : p.getUnidade()) |
1065 | { |
1065 | { |
1066 | u.setTotalHorasContacto(UnidadeImpl.calculateTotalHorasContacto(u.getHorasContacto())); |
1066 | u.setTotalHorasContacto(UnidadeImpl.calculateTotalHorasContacto(u.getHorasContacto())); |
1067 | } |
1067 | } |
1068 | } |
1068 | } |
1069 | } |
1069 | } |
1070 | } |
1070 | } |
1071 | } |
1071 | } |
1072 | } |
1072 | } |
1073 | } |
1073 | } |
1074 | 1074 | ||
1075 | public void generateFreshJsonPlanosEstudosFromXml(UserSession session) |
1075 | public void generateFreshJsonPlanosEstudosFromXml(UserSession session) |
1076 | { |
1076 | { |
1077 | List<CourseStudiesPlan> coursePlans = DaoFactory.getCourseStudiesPlanDaoImpl().findAll(); |
1077 | List<CourseStudiesPlan> coursePlans = DaoFactory.getCourseStudiesPlanDaoImpl().findAll(); |
1078 | for(CourseStudiesPlan courseStudiesPlanPersistente: coursePlans) |
1078 | for(CourseStudiesPlan courseStudiesPlanPersistente: coursePlans) |
1079 | { |
1079 | { |
1080 | try |
1080 | try |
1081 | { |
1081 | { |
1082 | logger.info("Generating JSON for " + courseStudiesPlanPersistente.getCourse().getName() + " version: " + courseStudiesPlanPersistente.getVersion()); |
1082 | logger.info("Generating JSON for " + courseStudiesPlanPersistente.getCourse().getName() + " version: " + courseStudiesPlanPersistente.getVersion()); |
1083 | Curso cursoPlano = loadCursoPlanoFromXml(courseStudiesPlanPersistente.getXml()); |
1083 | Curso cursoPlano = loadCursoPlanoFromXml(courseStudiesPlanPersistente.getXml()); |
1084 | if(cursoPlano != null) |
1084 | if(cursoPlano != null) |
1085 | { |
1085 | { |
1086 | for(Curso.Semestre s : cursoPlano.getSemestre()) |
1086 | for(Curso.Semestre s : cursoPlano.getSemestre()) |
1087 | { |
1087 | { |
1088 | SemestreImpl.setDescriptionsDefaults(s); |
1088 | SemestreImpl.setDescriptionsDefaults(s); |
1089 | } |
1089 | } |
1090 | //send to XML again |
1090 | //send to XML again |
1091 | JAXBContext jc = JAXBContext.newInstance(Curso.class); |
1091 | JAXBContext jc = JAXBContext.newInstance(Curso.class); |
1092 | Marshaller marshaller = jc.createMarshaller(); |
1092 | Marshaller marshaller = jc.createMarshaller(); |
1093 | marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); |
1093 | marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); |
1094 | 1.5.0/docs/api/java/io/StringWriter.html">StringWriter xml = new 1.5.0/docs/api/java/io/StringWriter.html">StringWriter(); |
1094 | 1.5.0/docs/api/java/io/StringWriter.html">StringWriter xml = new 1.5.0/docs/api/java/io/StringWriter.html">StringWriter(); |
1095 | marshaller.marshal(cursoPlano,xml); |
1095 | marshaller.marshal(cursoPlano,xml); |
1096 | courseStudiesPlanPersistente.setXml(xml.toString()); |
1096 | courseStudiesPlanPersistente.setXml(xml.toString()); |
1097 | 1.5.0/docs/api/java/lang/String.html">String json = CursoImpl.getGensonPlanoEstudosParaApiJsonWS().serialize(cursoPlano); |
1097 | 1.5.0/docs/api/java/lang/String.html">String json = CursoImpl.getGensonPlanoEstudosParaApiJsonWS().serialize(cursoPlano); |
1098 | //SETTING JSON in COURSE STUDIES PLAN |
1098 | //SETTING JSON in COURSE STUDIES PLAN |
1099 | courseStudiesPlanPersistente.setJson(json); |
1099 | courseStudiesPlanPersistente.setJson(json); |
1100 | } |
1100 | } |
1101 | 1101 | ||
1102 | } |
1102 | } |
1103 | catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
1103 | catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e) |
1104 | { |
1104 | { |
1105 | logger.error(e,e); |
1105 | logger.error(e,e); |
1106 | } |
1106 | } |
1107 | } |
1107 | } |
1108 | 1108 | ||
1109 | logger.info("GENERATING JSON FOR CLASS COURSE"); |
1109 | logger.info("GENERATING JSON FOR CLASS COURSE"); |
1110 | for(Course course: DaoFactory.getCourseDaoImpl().findAll()) |
1110 | for(Course course: DaoFactory.getCourseDaoImpl().findAll()) |
1111 | { |
1111 | { |
1112 | try { |
1112 | try { |
1113 | logger.info("generating json for course: " + course.getName() + " (" + course.getCode() + ")"); |
1113 | logger.info("generating json for course: " + course.getName() + " (" + course.getCode() + ")"); |
1114 | generateCourseJson(course); |
1114 | generateCourseJson(course); |
1115 | } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) { |
1115 | } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) { |
1116 | logger.error(e,e); |
1116 | logger.error(e,e); |
1117 | } |
1117 | } |
1118 | } |
1118 | } |
1119 | } |
1119 | } |
1120 | 1120 | ||
1121 | 1121 | ||
1122 | 1122 | ||
1123 | public List<CourseDepartment> loadDepartments() |
1123 | public List<CourseDepartment> loadDepartments() |
1124 | { |
1124 | { |
1125 | List<CourseDepartment> departments = DaoFactory.getCourseDepartmentDaoImpl().findAll(); |
1125 | List<CourseDepartment> departments = DaoFactory.getCourseDepartmentDaoImpl().findAll(); |
1126 | for(CourseDepartment dep: departments) |
1126 | for(CourseDepartment dep: departments) |
1127 | dep.getName(); |
1127 | dep.getName(); |
1128 | return departments; |
1128 | return departments; |
1129 | 1129 | ||
1130 | } |
1130 | } |
1131 | 1131 | ||
1132 | 1132 | ||
1133 | public Teacher addTeacherCommission(1.5.0/docs/api/java/lang/String.html">String teacherId,1.5.0/docs/api/java/lang/String.html">String courseId, UserSession session) |
1133 | public Teacher addTeacherCommission(1.5.0/docs/api/java/lang/String.html">String teacherId,1.5.0/docs/api/java/lang/String.html">String courseId, UserSession session) |
1134 | { |
1134 | { |
1135 | Course course = DaoFactory.getCourseDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(courseId)); |
1135 | Course course = DaoFactory.getCourseDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(courseId)); |
1136 | Teacher t = DaoFactory.getTeacherDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(teacherId)); |
1136 | Teacher t = DaoFactory.getTeacherDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(teacherId)); |
1137 | t.addRole(course.getValidationRole()); |
1137 | t.addRole(course.getValidationRole()); |
1138 | return t; |
1138 | return t; |
1139 | } |
1139 | } |
1140 | 1140 | ||
1141 | public Teacher removeTeacherCommission(1.5.0/docs/api/java/lang/String.html">String teacherId,1.5.0/docs/api/java/lang/String.html">String courseId, UserSession session) |
1141 | public Teacher removeTeacherCommission(1.5.0/docs/api/java/lang/String.html">String teacherId,1.5.0/docs/api/java/lang/String.html">String courseId, UserSession session) |
1142 | { |
1142 | { |
1143 | Course course = DaoFactory.getCourseDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(courseId)); |
1143 | Course course = DaoFactory.getCourseDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(courseId)); |
1144 | Teacher t = DaoFactory.getTeacherDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(teacherId)); |
1144 | Teacher t = DaoFactory.getTeacherDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(teacherId)); |
1145 | t.removeRole(course.getValidationRole()); |
1145 | t.removeRole(course.getValidationRole()); |
1146 | return t; |
1146 | return t; |
1147 | } |
1147 | } |
1148 | 1148 | ||
1149 | 1149 | ||
1150 | public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) |
1150 | public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) |
1151 | { |
1151 | { |
1152 | AbstractDao.getCurrentSession().beginTransaction(); |
1152 | AbstractDao.getCurrentSession().beginTransaction(); |
1153 | new CoursesService().generateFreshJsonPlanosEstudosFromXml(null); |
1153 | new CoursesService().generateFreshJsonPlanosEstudosFromXml(null); |
1154 | AbstractDao.getCurrentSession().getTransaction().commit(); |
1154 | AbstractDao.getCurrentSession().getTransaction().commit(); |
1155 | } |
1155 | } |
1156 | 1156 | ||
1157 | public StudiesPlanImporter importStudiesPlanVersionFromFile(5+0%2Fdocs%2Fapi+InputStream">InputStream stream, 1.5.0/docs/api/java/lang/Long.html">Long studiesPlanId, UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1157 | public StudiesPlanImporter importStudiesPlanVersionFromFile(5+0%2Fdocs%2Fapi+InputStream">InputStream stream, 1.5.0/docs/api/java/lang/Long.html">Long studiesPlanId, UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1158 | { |
1158 | { |
1159 | StudiesPlanImporter importer = new StudiesPlanImporter(); |
1159 | StudiesPlanImporter importer = new StudiesPlanImporter(); |
1160 | importer.parseFile(stream); |
1160 | importer.parseFile(stream); |
1161 | 1.5.0/docs/api/java/lang/System.html">System.out.println(importer.getLog()); |
1161 | 1.5.0/docs/api/java/lang/System.html">System.out.println(importer.getLog()); |
1162 | CourseStudiesPlan plan = DaoFactory.getCourseStudiesPlanDaoImpl().load(studiesPlanId); |
1162 | CourseStudiesPlan plan = DaoFactory.getCourseStudiesPlanDaoImpl().load(studiesPlanId); |
1163 | plan.setImportLog(importer.getLog()); |
1163 | plan.setImportLog(importer.getLog()); |
1164 | return importer; |
1164 | return importer; |
1165 | } |
1165 | } |
1166 | public StudiesPlanImporter mergeStudiesPlanVersionFromFile(5+0%2Fdocs%2Fapi+InputStream">InputStream stream, 1.5.0/docs/api/java/lang/Long.html">Long studiesPlanId, UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1166 | public StudiesPlanImporter mergeStudiesPlanVersionFromFile(5+0%2Fdocs%2Fapi+InputStream">InputStream stream, 1.5.0/docs/api/java/lang/Long.html">Long studiesPlanId, UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1167 | { |
1167 | { |
1168 | StudiesPlanImporter importer = new StudiesPlanImporter(); |
1168 | StudiesPlanImporter importer = new StudiesPlanImporter(); |
1169 | importer.parseFile(stream); |
1169 | importer.parseFile(stream); |
1170 | 1.5.0/docs/api/java/lang/System.html">System.out.println(importer.getLog()); |
1170 | 1.5.0/docs/api/java/lang/System.html">System.out.println(importer.getLog()); |
1171 | CourseStudiesPlan plan = DaoFactory.getCourseStudiesPlanDaoImpl().load(studiesPlanId); |
1171 | CourseStudiesPlan plan = DaoFactory.getCourseStudiesPlanDaoImpl().load(studiesPlanId); |
1172 | plan.setImportLog(plan.getImportLog() + "\n\n############\n\n##MERGING\n\n" + importer.getLog()); |
1172 | plan.setImportLog(plan.getImportLog() + "\n\n############\n\n##MERGING\n\n" + importer.getLog()); |
1173 | return importer; |
1173 | return importer; |
1174 | } |
1174 | } |
1175 | 1175 | ||
1176 | public ReplaceRoleResult createRoleCourseComission(long courseId,UserSession userSession) throws AccessDeniedException |
1176 | public ReplaceRoleResult createRoleCourseComission(long courseId,UserSession userSession) throws AccessDeniedException |
1177 | { |
1177 | { |
1178 | Course c = DaoFactory.getCourseDaoImpl().load(courseId); |
1178 | Course c = DaoFactory.getCourseDaoImpl().load(courseId); |
1179 | 1.5.0/docs/api/java/lang/String.html">String normalizedName = StringsUtils.getNormalizedNameSafeforCode(c.getName()); |
1179 | 1.5.0/docs/api/java/lang/String.html">String normalizedName = StringsUtils.getNormalizedNameSafeforCode(c.getName()); |
1180 | if(normalizedName == null) |
1180 | if(normalizedName == null) |
1181 | throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("Erro o curso " + c.getId() +" + nao tem nome"); |
1181 | throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("Erro o curso " + c.getId() +" + nao tem nome"); |
1182 | 1182 | ||
1183 | 1.5.0/docs/api/java/lang/String.html">String roleValidation = "courseValidateProgram" + normalizedName; |
1183 | 1.5.0/docs/api/java/lang/String.html">String roleValidation = "courseValidateProgram" + normalizedName; |
1184 | 1.5.0/docs/api/java/lang/String.html">String oldValidationRole = c.getValidationRole(); |
1184 | 1.5.0/docs/api/java/lang/String.html">String oldValidationRole = c.getValidationRole(); |
1185 | 1.5.0/docs/api/java/lang/String.html">String nomeRole = "Comissão de Curso de " + c.getName(); |
1185 | 1.5.0/docs/api/java/lang/String.html">String nomeRole = "Comissão de Curso de " + c.getName(); |
1186 | try{ |
1186 | try{ |
1187 | ReplaceRoleResult result = new UserRoleConfigService().createNewNormalizedRoleService(oldValidationRole,nomeRole,roleValidation,userSession); |
1187 | ReplaceRoleResult result = new UserRoleConfigService().createNewNormalizedRoleService(oldValidationRole,nomeRole,roleValidation,userSession); |
1188 | c.setValidationRole(roleValidation); |
1188 | c.setValidationRole(roleValidation); |
1189 | return result; |
1189 | return result; |
1190 | }catch(AccessDeniedException e) |
1190 | }catch(AccessDeniedException e) |
1191 | { |
1191 | { |
1192 | throw e; |
1192 | throw e; |
1193 | } |
1193 | } |
1194 | } |
1194 | } |
1195 | 1195 | ||
1196 | 1196 | ||
1197 | 1197 | ||
1198 | public Teacher changeCoordinator(long teacherId,long courseId,UserSession userSession) |
1198 | public Teacher changeCoordinator(long teacherId,long courseId,UserSession userSession) |
1199 | { |
1199 | { |
1200 | Course c = DaoFactory.getCourseDaoImpl().load(courseId); |
1200 | Course c = DaoFactory.getCourseDaoImpl().load(courseId); |
1201 | Teacher t = DaoFactory.getTeacherDaoImpl().load(teacherId); |
1201 | Teacher t = DaoFactory.getTeacherDaoImpl().load(teacherId); |
1202 | c.setCoordinator(t); |
1202 | c.setCoordinator(t); |
1203 | t = DaoFactory.getTeacherDaoImpl().narrow(t); |
1203 | t = DaoFactory.getTeacherDaoImpl().narrow(t); |
1204 | return t; |
1204 | return t; |
1205 | } |
1205 | } |
1206 | 1206 | ||
1207 | public CourseDepartmentImpl updateDepartmentFromJson(1.5.0/docs/api/java/lang/String.html">String json,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1207 | public CourseDepartmentImpl updateDepartmentFromJson(1.5.0/docs/api/java/lang/String.html">String json,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1208 | { |
1208 | { |
1209 | CourseDepartmentImpl courseDepartment = CourseDepartmentImpl.loadFromJson(json); |
1209 | CourseDepartmentImpl courseDepartment = CourseDepartmentImpl.loadFromJson(json); |
1210 | 1210 | ||
1211 | 1211 | ||
1212 | 1212 | ||
1213 | if(!courseDepartment.getSiglaNova().equals(courseDepartment.getSigla())) |
1213 | if(!courseDepartment.getSiglaNova().equals(courseDepartment.getSigla())) |
1214 | { |
1214 | { |
1215 | //courseDepartmentPersistent.setSigla(courseDepartment.getSiglaNova()); |
1215 | //courseDepartmentPersistent.setSigla(courseDepartment.getSiglaNova()); |
1216 | 1.5.0/docs/api/javax/management/Query.html">Query q = AbstractDao.getCurrentSession().createQuery("update " + CourseDepartment.class.getName() + " d " + |
1216 | 1.5.0/docs/api/javax/management/Query.html">Query q = AbstractDao.getCurrentSession().createQuery("update " + CourseDepartment.class.getName() + " d " + |
1217 | " set d.sigla = :siglaNova where d.sigla = :sigla"); |
1217 | " set d.sigla = :siglaNova where d.sigla = :sigla"); |
1218 | q.setString("siglaNova",courseDepartment.getSiglaNova()); |
1218 | q.setString("siglaNova",courseDepartment.getSiglaNova()); |
1219 | q.setString("sigla",courseDepartment.getSigla()); |
1219 | q.setString("sigla",courseDepartment.getSigla()); |
1220 | q.executeUpdate(); |
1220 | q.executeUpdate(); |
1221 | //courseDepartmentPersistent = (CourseDepartmentImpl) DaoFactory.getCourseDepartmentDaoImpl().load(courseDepartment.getSiglaNova()); |
1221 | //courseDepartmentPersistent = (CourseDepartmentImpl) DaoFactory.getCourseDepartmentDaoImpl().load(courseDepartment.getSiglaNova()); |
1222 | } |
1222 | } |
1223 | CourseDepartmentImpl courseDepartmentPersistent = (CourseDepartmentImpl) DaoFactory.getCourseDepartmentDaoImpl().load(courseDepartment.getSiglaNova()); |
1223 | CourseDepartmentImpl courseDepartmentPersistent = (CourseDepartmentImpl) DaoFactory.getCourseDepartmentDaoImpl().load(courseDepartment.getSiglaNova()); |
1224 | //courseDepartmentPersistent.setSigla(courseDepartment.getSigla()); |
1224 | //courseDepartmentPersistent.setSigla(courseDepartment.getSigla()); |
1225 | courseDepartmentPersistent.setActive(courseDepartment.isActive()); |
1225 | courseDepartmentPersistent.setActive(courseDepartment.isActive()); |
1226 | courseDepartmentPersistent.setName(courseDepartment.getName()); |
1226 | courseDepartmentPersistent.setName(courseDepartment.getName()); |
1227 | courseDepartmentPersistent.setNameEs(courseDepartment.getNameEs()); |
1227 | courseDepartmentPersistent.setNameEs(courseDepartment.getNameEs()); |
1228 | courseDepartmentPersistent.setNameEn(courseDepartment.getNameEs()); |
1228 | courseDepartmentPersistent.setNameEn(courseDepartment.getNameEs()); |
1229 | courseDepartmentPersistent.setNameFr(courseDepartment.getNameFr()); |
1229 | courseDepartmentPersistent.setNameFr(courseDepartment.getNameFr()); |
1230 | //courseDepartmentPersistent.setInstitutionalCode(courseDepartment.getInstitutionalCode()); |
1230 | //courseDepartmentPersistent.setInstitutionalCode(courseDepartment.getInstitutionalCode()); |
1231 | courseDepartmentPersistent.setBoardRole(courseDepartment.getBoardRole()); |
1231 | courseDepartmentPersistent.setBoardRole(courseDepartment.getBoardRole()); |
1232 | courseDepartmentPersistent.setDirectorRole(courseDepartment.getDirectorRole()); |
1232 | courseDepartmentPersistent.setDirectorRole(courseDepartment.getDirectorRole()); |
1233 | if(courseDepartment.getCourseSchool() != null && courseDepartment.getCourseSchool().getId() > 0) |
1233 | if(courseDepartment.getCourseSchool() != null && courseDepartment.getCourseSchool().getId() > 0) |
1234 | { |
1234 | { |
1235 | CourseSchoolImpl courseSchool = (CourseSchoolImpl) DaoFactory.getCourseSchoolDaoImpl().load(courseDepartment.getCourseSchool().getId()); |
1235 | CourseSchoolImpl courseSchool = (CourseSchoolImpl) DaoFactory.getCourseSchoolDaoImpl().load(courseDepartment.getCourseSchool().getId()); |
1236 | courseDepartmentPersistent.setCourseSchool(courseSchool); |
1236 | courseDepartmentPersistent.setCourseSchool(courseSchool); |
1237 | } |
1237 | } |
1238 | else |
1238 | else |
1239 | courseDepartmentPersistent.setCourseSchool(null); |
1239 | courseDepartmentPersistent.setCourseSchool(null); |
1240 | return courseDepartmentPersistent; |
1240 | return courseDepartmentPersistent; |
1241 | 1241 | ||
1242 | } |
1242 | } |
1243 | 1243 | ||
1244 | public CourseDepartmentImpl removeDepartmentFromJson(1.5.0/docs/api/java/lang/String.html">String json,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1244 | public CourseDepartmentImpl removeDepartmentFromJson(1.5.0/docs/api/java/lang/String.html">String json,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1245 | { |
1245 | { |
1246 | CourseDepartmentImpl courseDepartment = CourseDepartmentImpl.loadFromJson(json); |
1246 | CourseDepartmentImpl courseDepartment = CourseDepartmentImpl.loadFromJson(json); |
1247 | CourseDepartmentImpl courseDepartmentPersistent = (CourseDepartmentImpl) DaoFactory.getCourseDepartmentDaoImpl().load(courseDepartment.getSigla()); |
1247 | CourseDepartmentImpl courseDepartmentPersistent = (CourseDepartmentImpl) DaoFactory.getCourseDepartmentDaoImpl().load(courseDepartment.getSigla()); |
1248 | DaoFactory.getCourseDepartmentDaoImpl().delete(courseDepartmentPersistent); |
1248 | DaoFactory.getCourseDepartmentDaoImpl().delete(courseDepartmentPersistent); |
1249 | return courseDepartmentPersistent; |
1249 | return courseDepartmentPersistent; |
1250 | 1250 | ||
1251 | } |
1251 | } |
1252 | 1252 | ||
1253 | public CourseDepartmentImpl newDepartmentFromJson(UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1253 | public CourseDepartmentImpl newDepartmentFromJson(UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1254 | { |
1254 | { |
1255 | CourseDepartmentImpl courseDepartmentPersistent = DomainObjectFactory.createCourseDepartmentImpl(); |
1255 | CourseDepartmentImpl courseDepartmentPersistent = DomainObjectFactory.createCourseDepartmentImpl(); |
1256 | 1256 | ||
1257 | courseDepartmentPersistent.setSigla(BytesUtils.generateKey().substring(0,10)); |
1257 | courseDepartmentPersistent.setSigla(BytesUtils.generateKey().substring(0,10)); |
1258 | courseDepartmentPersistent.setSiglaNova(courseDepartmentPersistent.getSigla()); |
1258 | courseDepartmentPersistent.setSiglaNova(courseDepartmentPersistent.getSigla()); |
1259 | courseDepartmentPersistent.setActive(false); |
1259 | courseDepartmentPersistent.setActive(false); |
1260 | DaoFactory.getCourseDepartmentDaoImpl().save(courseDepartmentPersistent); |
1260 | DaoFactory.getCourseDepartmentDaoImpl().save(courseDepartmentPersistent); |
1261 | return courseDepartmentPersistent; |
1261 | return courseDepartmentPersistent; |
1262 | 1262 | ||
1263 | } |
1263 | } |
1264 | 1264 | ||
1265 | /** |
1265 | /** |
1266 | * Cria um conjunto de roles novos para um determinado departamento |
1266 | * Cria um conjunto de roles novos para um determinado departamento |
1267 | * chama o serviço tier1 UserRoleConfigService.createNewNormalizedRoleService |
1267 | * chama o serviço tier1 UserRoleConfigService.createNewNormalizedRoleService |
1268 | * @param session |
1268 | * @param session |
1269 | * @return |
1269 | * @return |
1270 | * @throws IOException |
1270 | * @throws IOException |
1271 | * @throws AccessDeniedException |
1271 | * @throws AccessDeniedException |
1272 | */ |
1272 | */ |
1273 | public CourseDepartmentImpl newDepartmentRolesFromJson(1.5.0/docs/api/java/lang/String.html">String json,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException, AccessDeniedException { |
1273 | public CourseDepartmentImpl newDepartmentRolesFromJson(1.5.0/docs/api/java/lang/String.html">String json,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException, AccessDeniedException { |
1274 | CourseDepartmentImpl courseDepartment = CourseDepartmentImpl.loadFromJson(json); |
1274 | CourseDepartmentImpl courseDepartment = CourseDepartmentImpl.loadFromJson(json); |
1275 | CourseDepartmentImpl courseDepartmentPersistent = (CourseDepartmentImpl) DaoFactory.getCourseDepartmentDaoImpl().findBySigla(courseDepartment.getSigla()); |
1275 | CourseDepartmentImpl courseDepartmentPersistent = (CourseDepartmentImpl) DaoFactory.getCourseDepartmentDaoImpl().findBySigla(courseDepartment.getSigla()); |
1276 | 1276 | ||
1277 | UserRoleConfigService userRoleConfigService = new UserRoleConfigService(); |
1277 | UserRoleConfigService userRoleConfigService = new UserRoleConfigService(); |
1278 | 1.5.0/docs/api/java/lang/String.html">String normalizedName = StringsUtils.getNormalizedNameSafeforCode(courseDepartmentPersistent.getName()); |
1278 | 1.5.0/docs/api/java/lang/String.html">String normalizedName = StringsUtils.getNormalizedNameSafeforCode(courseDepartmentPersistent.getName()); |
1279 | if(normalizedName == null) |
1279 | if(normalizedName == null) |
1280 | throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("Erro o Departamento " + courseDepartmentPersistent.getSigla() +" + nao tem nome"); |
1280 | throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("Erro o Departamento " + courseDepartmentPersistent.getSigla() +" + nao tem nome"); |
1281 | 1281 | ||
1282 | 1282 | ||
1283 | 1.5.0/docs/api/java/lang/String.html">String nomeRole = "Departamento Direcção - " + courseDepartmentPersistent.getName(); |
1283 | 1.5.0/docs/api/java/lang/String.html">String nomeRole = "Departamento Direcção - " + courseDepartmentPersistent.getName(); |
1284 | 1.5.0/docs/api/java/lang/String.html">String oldRole = courseDepartmentPersistent.getBoardRole(); |
1284 | 1.5.0/docs/api/java/lang/String.html">String oldRole = courseDepartmentPersistent.getBoardRole(); |
1285 | 1.5.0/docs/api/java/lang/String.html">String newRoleStr = "department.board." + normalizedName; |
1285 | 1.5.0/docs/api/java/lang/String.html">String newRoleStr = "department.board." + normalizedName; |
1286 | try |
1286 | try |
1287 | { |
1287 | { |
1288 | userRoleConfigService.createNewNormalizedRoleService(oldRole,nomeRole,newRoleStr, session); |
1288 | userRoleConfigService.createNewNormalizedRoleService(oldRole,nomeRole,newRoleStr, session); |
1289 | courseDepartmentPersistent.setBoardRole(newRoleStr); |
1289 | courseDepartmentPersistent.setBoardRole(newRoleStr); |
1290 | } catch (AccessDeniedException e) { |
1290 | } catch (AccessDeniedException e) { |
1291 | logger.error(e,e); |
1291 | logger.error(e,e); |
1292 | throw e; |
1292 | throw e; |
1293 | } |
1293 | } |
1294 | 1294 | ||
1295 | 1295 | ||
1296 | nomeRole = "Departamento Diretor - " + courseDepartmentPersistent.getName(); |
1296 | nomeRole = "Departamento Diretor - " + courseDepartmentPersistent.getName(); |
1297 | oldRole = courseDepartmentPersistent.getDirectorRole(); |
1297 | oldRole = courseDepartmentPersistent.getDirectorRole(); |
1298 | newRoleStr = "department.diretor." + normalizedName; |
1298 | newRoleStr = "department.diretor." + normalizedName; |
1299 | 1299 | ||
1300 | try { |
1300 | try { |
1301 | userRoleConfigService.createNewNormalizedRoleService(oldRole,nomeRole,newRoleStr, session); |
1301 | userRoleConfigService.createNewNormalizedRoleService(oldRole,nomeRole,newRoleStr, session); |
1302 | courseDepartmentPersistent.setDirectorRole(newRoleStr); |
1302 | courseDepartmentPersistent.setDirectorRole(newRoleStr); |
1303 | } catch (AccessDeniedException e) { |
1303 | } catch (AccessDeniedException e) { |
1304 | logger.error(e,e); |
1304 | logger.error(e,e); |
1305 | throw e; |
1305 | throw e; |
1306 | } |
1306 | } |
1307 | 1307 | ||
1308 | return courseDepartmentPersistent; |
1308 | return courseDepartmentPersistent; |
1309 | } |
1309 | } |
1310 | 1310 | ||
1311 | 1311 | ||
1312 | 1312 | ||
1313 | 1313 | ||
1314 | public CourseSchoolImpl updateSchoolFromJson(1.5.0/docs/api/java/lang/String.html">String json,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1314 | public CourseSchoolImpl updateSchoolFromJson(1.5.0/docs/api/java/lang/String.html">String json,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1315 | { |
1315 | { |
1316 | CourseSchoolImpl courseSchool = CourseSchoolImpl.loadFromJson(json); |
1316 | CourseSchoolImpl courseSchool = CourseSchoolImpl.loadFromJson(json); |
1317 | CourseSchoolImpl courseSchoolPersistent = (CourseSchoolImpl) DaoFactory.getCourseSchoolDaoImpl().load(courseSchool.getId()); |
1317 | CourseSchoolImpl courseSchoolPersistent = (CourseSchoolImpl) DaoFactory.getCourseSchoolDaoImpl().load(courseSchool.getId()); |
1318 | 1318 | ||
1319 | courseSchoolPersistent.setActive(courseSchool.isActive()); |
1319 | courseSchoolPersistent.setActive(courseSchool.isActive()); |
1320 | courseSchoolPersistent.setName(courseSchool.getName()); |
1320 | courseSchoolPersistent.setName(courseSchool.getName()); |
1321 | courseSchoolPersistent.setNameEs(courseSchool.getNameEs()); |
1321 | courseSchoolPersistent.setNameEs(courseSchool.getNameEs()); |
1322 | courseSchoolPersistent.setNameEn(courseSchool.getNameEs()); |
1322 | courseSchoolPersistent.setNameEn(courseSchool.getNameEs()); |
1323 | courseSchoolPersistent.setNameFr(courseSchool.getNameFr()); |
1323 | courseSchoolPersistent.setNameFr(courseSchool.getNameFr()); |
1324 | courseSchoolPersistent.setInstitutionalCode(courseSchool.getInstitutionalCode()); |
1324 | courseSchoolPersistent.setInstitutionalCode(courseSchool.getInstitutionalCode()); |
1325 | courseSchoolPersistent.setInitials(courseSchool.getInitials()); |
1325 | courseSchoolPersistent.setInitials(courseSchool.getInitials()); |
1326 | 1326 | ||
1327 | courseSchoolPersistent.setSchoolDirectorRole(courseSchool.getSchoolDirectorRole()); |
1327 | courseSchoolPersistent.setSchoolDirectorRole(courseSchool.getSchoolDirectorRole()); |
1328 | courseSchoolPersistent.setSchoolBoardRole(courseSchool.getSchoolBoardRole()); |
1328 | courseSchoolPersistent.setSchoolBoardRole(courseSchool.getSchoolBoardRole()); |
1329 | courseSchoolPersistent.setSchoolSecretariadoRole(courseSchool.getSchoolSecretariadoRole()); |
1329 | courseSchoolPersistent.setSchoolSecretariadoRole(courseSchool.getSchoolSecretariadoRole()); |
1330 | 1330 | ||
1331 | courseSchoolPersistent.setCtcPresidentRole(courseSchool.getCtcPresidentRole()); |
1331 | courseSchoolPersistent.setCtcPresidentRole(courseSchool.getCtcPresidentRole()); |
1332 | courseSchoolPersistent.setCtcMemberRole(courseSchool.getCtcMemberRole()); |
1332 | courseSchoolPersistent.setCtcMemberRole(courseSchool.getCtcMemberRole()); |
1333 | courseSchoolPersistent.setCtcSecretariadoRole(courseSchool.getCtcSecretariadoRole()); |
1333 | courseSchoolPersistent.setCtcSecretariadoRole(courseSchool.getCtcSecretariadoRole()); |
1334 | 1334 | ||
1335 | courseSchoolPersistent.setPedagogicoPresidentRole(courseSchool.getPedagogicoPresidentRole()); |
1335 | courseSchoolPersistent.setPedagogicoPresidentRole(courseSchool.getPedagogicoPresidentRole()); |
1336 | courseSchoolPersistent.setPedagogicoMemberRole(courseSchool.getPedagogicoMemberRole()); |
1336 | courseSchoolPersistent.setPedagogicoMemberRole(courseSchool.getPedagogicoMemberRole()); |
1337 | courseSchoolPersistent.setPedagogicoSecretariadoRole(courseSchool.getPedagogicoSecretariadoRole()); |
1337 | courseSchoolPersistent.setPedagogicoSecretariadoRole(courseSchool.getPedagogicoSecretariadoRole()); |
1338 | 1338 | ||
1339 | courseSchoolPersistent.setFuncionarioRole(courseSchool.getFuncionarioRole()); |
1339 | courseSchoolPersistent.setFuncionarioRole(courseSchool.getFuncionarioRole()); |
1340 | courseSchoolPersistent.setTeacherRole(courseSchool.getTeacherRole()); |
1340 | courseSchoolPersistent.setTeacherRole(courseSchool.getTeacherRole()); |
1341 | courseSchoolPersistent.setStudentRole(courseSchool.getStudentRole()); |
1341 | courseSchoolPersistent.setStudentRole(courseSchool.getStudentRole()); |
1342 | 1342 | ||
1343 | return courseSchoolPersistent; |
1343 | return courseSchoolPersistent; |
1344 | 1344 | ||
1345 | } |
1345 | } |
1346 | 1346 | ||
1347 | 1347 | ||
1348 | public CourseSchoolImpl newSchoolFromJson(UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1348 | public CourseSchoolImpl newSchoolFromJson(UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1349 | { |
1349 | { |
1350 | CourseSchoolImpl courseSchoolPersistent = DomainObjectFactory.createCourseSchoolImpl(); |
1350 | CourseSchoolImpl courseSchoolPersistent = DomainObjectFactory.createCourseSchoolImpl(); |
1351 | 1351 | ||
1352 | courseSchoolPersistent.setActive(false); |
1352 | courseSchoolPersistent.setActive(false); |
1353 | DaoFactory.getCourseSchoolDaoImpl().save(courseSchoolPersistent); |
1353 | DaoFactory.getCourseSchoolDaoImpl().save(courseSchoolPersistent); |
1354 | return courseSchoolPersistent; |
1354 | return courseSchoolPersistent; |
1355 | 1355 | ||
1356 | } |
1356 | } |
1357 | 1357 | ||
1358 | public CourseSchoolImpl removeSchoolFromJson(1.5.0/docs/api/java/lang/String.html">String json,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1358 | public CourseSchoolImpl removeSchoolFromJson(1.5.0/docs/api/java/lang/String.html">String json,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException |
1359 | { |
1359 | { |
1360 | CourseSchoolImpl courseSchool = CourseSchoolImpl.loadFromJson(json); |
1360 | CourseSchoolImpl courseSchool = CourseSchoolImpl.loadFromJson(json); |
1361 | CourseSchoolImpl courseSchoolPersistent = (CourseSchoolImpl) DaoFactory.getCourseSchoolDaoImpl().load(courseSchool.getId()); |
1361 | CourseSchoolImpl courseSchoolPersistent = (CourseSchoolImpl) DaoFactory.getCourseSchoolDaoImpl().load(courseSchool.getId()); |
1362 | DaoFactory.getCourseSchoolDaoImpl().delete(courseSchoolPersistent); |
1362 | DaoFactory.getCourseSchoolDaoImpl().delete(courseSchoolPersistent); |
1363 | return courseSchoolPersistent; |
1363 | return courseSchoolPersistent; |
1364 | 1364 | ||
1365 | } |
1365 | } |
1366 | 1366 | ||
1367 | /* |
1367 | /* |
1368 | public static void main(String[] args) throws JAXBException, IOException { |
1368 | public static void main(String[] args) throws JAXBException, IOException { |
1369 | 1369 | ||
1370 | String json = "{\"anoPlanoSiges\":null,\"codigoPlanoSiges\":null,\"dep\":null,\"descPlanoSiges\":null,\"nome\":null,\"semestre\":[{\"id\":\"S1\",\"notas\":null,\"perfil\":[],\"semestreDesc\":\"Semestre 1\",\"semestreDescEn\":\"Semester 1\",\"semestreDescEs\":\"Semestre 1\",\"semestreDescFr\":\"Semestre 1\",\"semestreId\":null,\"unidade\":[{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Português — LÃngua e Literatura\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"150\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:12\",\"horasContacto\":{\"tP\":\"60\",\"oT\":\"15\"},\"eCTS\":\"6\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Geografia\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"125\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:16\",\"horasContacto\":{\"tP\":\"45\",\"oT\":\"15\"},\"eCTS\":\"5\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"História\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"125\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:20\",\"horasContacto\":{\"tP\":\"45\",\"oT\":\"15\"},\"eCTS\":\"5\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"LinguÃstica e Análise do Discurso\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"150\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:24\",\"horasContacto\":{\"tP\":\"60\",\"oT\":\"15\"},\"eCTS\":\"6\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Matemática no 1.o Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"125\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:28\",\"horasContacto\":{\"tP\":\"45\",\"oT\":\"15\"},\"eCTS\":\"5\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Educação para a Saúde\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"75\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:32\",\"horasContacto\":{\"tP\":\"30\",\"oT\":\"7\"},\"eCTS\":\"3\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Música, Emoção e Criatividade\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"75\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:36\",\"horasContacto\":{\"tP\":\"30\",\"oT\":\"7\"},\"eCTS\":\"3\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Educação para a Cidadania\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"75\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:40\",\"horasContacto\":{\"tP\":\"30\",\"oT\":\"7\"},\"eCTS\":\"3\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Descobrir a Matemática\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"75\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:44\",\"horasContacto\":{\"tP\":\"30\",\"oT\":\"7\"},\"eCTS\":\"3\"}],\"type\":\"semestre\",\"$$hashKey\":\"object:6\"},{\"id\":\"S2\",\"notas\":null,\"perfil\":[],\"semestreDesc\":\"Semestre 1\",\"semestreDescEn\":\"Semester 1\",\"semestreDescEs\":\"Semestre 1\",\"semestreDescFr\":\"Semestre 1\",\"semestreId\":null,\"unidade\":[{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Didática do Português no 1º Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"150\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:54\",\"eCTS\":\"6\",\"horasContacto\":{\"tP\":\"60\",\"oT\":\"15\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Didática do Estudo do Meio no 1º Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"150\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:58\",\"eCTS\":\"6\",\"horasContacto\":{\"tP\":\"60\",\"oT\":\"15\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Didática da Matemática no 1º Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"150\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:62\",\"eCTS\":\"6\",\"horasContacto\":{\"tP\":\"60\",\"oT\":\"15\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Didática das Expressões no 1º Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"150\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:66\",\"eCTS\":\"6\",\"horasContacto\":{\"tP\":\"60\",\"oT\":\"15\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Psicologia da Educação\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"75\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:70\",\"eCTS\":\"3\",\"horasContacto\":{\"tP\":\"30\",\"oT\":\"7\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Investigação em Educação\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"75\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:74\",\"eCTS\":\"3\",\"horasContacto\":{\"tP\":\"30\",\"oT\":\"7\"}}],\"type\":\"semestre\",\"$$hashKey\":\"object:48\"},{\"id\":\"S3\",\"notas\":null,\"perfil\":[],\"semestreDesc\":\"Semestre 1\",\"semestreDescEn\":\"Semester 1\",\"semestreDescEs\":\"Semestre 1\",\"semestreDescFr\":\"Semestre 1\",\"semestreId\":null,\"unidade\":[{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Prática de Ensino Supervisionada no 1º Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"500\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:90\",\"eCTS\":\"20\",\"horasContacto\":{\"s\":\"30\",\"e\":\"270\",\"oT\":\"45\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Seminário de Investigação I\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"50\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:98\",\"eCTS\":\"2\",\"horasContacto\":{\"s\":\"20\",\"oT\":\"10\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Didática da História e Geografia de Portugal no 2º Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"100\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:94\",\"eCTS\":\"4\",\"horasContacto\":{\"tP\":\"35\",\"oT\":\"15\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Didática do Português no 2º Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"100\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:102\",\"eCTS\":\"4\",\"horasContacto\":{\"oT\":\"15\",\"tP\":\"35\"}}],\"type\":\"semestre\",\"$$hashKey\":\"object:78\"},{\"id\":\"S4\",\"notas\":null,\"perfil\":[],\"semestreDesc\":\"Semestre 1\",\"semestreDescEn\":\"Semester 1\",\"semestreDescEs\":\"Semestre 1\",\"semestreDescFr\":\"Semestre 1\",\"semestreId\":null,\"unidade\":[{\"dep\":\"\",\"ects\":\"\",\"nome\":\"\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":0,\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:106\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":0,\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:110\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":0,\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:114\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":0,\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:118\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":0,\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:122\"}],\"type\":\"semestre\",\"$$hashKey\":\"object:84\"}],\"siges\":null}"; |
1370 | String json = "{\"anoPlanoSiges\":null,\"codigoPlanoSiges\":null,\"dep\":null,\"descPlanoSiges\":null,\"nome\":null,\"semestre\":[{\"id\":\"S1\",\"notas\":null,\"perfil\":[],\"semestreDesc\":\"Semestre 1\",\"semestreDescEn\":\"Semester 1\",\"semestreDescEs\":\"Semestre 1\",\"semestreDescFr\":\"Semestre 1\",\"semestreId\":null,\"unidade\":[{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Português — Língua e Literatura\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"150\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:12\",\"horasContacto\":{\"tP\":\"60\",\"oT\":\"15\"},\"eCTS\":\"6\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Geografia\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"125\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:16\",\"horasContacto\":{\"tP\":\"45\",\"oT\":\"15\"},\"eCTS\":\"5\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"História\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"125\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:20\",\"horasContacto\":{\"tP\":\"45\",\"oT\":\"15\"},\"eCTS\":\"5\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Linguística e Análise do Discurso\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"150\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:24\",\"horasContacto\":{\"tP\":\"60\",\"oT\":\"15\"},\"eCTS\":\"6\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Matemática no 1.o Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"125\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:28\",\"horasContacto\":{\"tP\":\"45\",\"oT\":\"15\"},\"eCTS\":\"5\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Educação para a Saúde\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"75\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:32\",\"horasContacto\":{\"tP\":\"30\",\"oT\":\"7\"},\"eCTS\":\"3\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Música, Emoção e Criatividade\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"75\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:36\",\"horasContacto\":{\"tP\":\"30\",\"oT\":\"7\"},\"eCTS\":\"3\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Educação para a Cidadania\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"75\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:40\",\"horasContacto\":{\"tP\":\"30\",\"oT\":\"7\"},\"eCTS\":\"3\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Descobrir a Matemática\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"75\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:44\",\"horasContacto\":{\"tP\":\"30\",\"oT\":\"7\"},\"eCTS\":\"3\"}],\"type\":\"semestre\",\"$$hashKey\":\"object:6\"},{\"id\":\"S2\",\"notas\":null,\"perfil\":[],\"semestreDesc\":\"Semestre 1\",\"semestreDescEn\":\"Semester 1\",\"semestreDescEs\":\"Semestre 1\",\"semestreDescFr\":\"Semestre 1\",\"semestreId\":null,\"unidade\":[{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Didática do Português no 1º Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"150\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:54\",\"eCTS\":\"6\",\"horasContacto\":{\"tP\":\"60\",\"oT\":\"15\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Didática do Estudo do Meio no 1º Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"150\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:58\",\"eCTS\":\"6\",\"horasContacto\":{\"tP\":\"60\",\"oT\":\"15\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Didática da Matemática no 1º Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"150\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:62\",\"eCTS\":\"6\",\"horasContacto\":{\"tP\":\"60\",\"oT\":\"15\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Didática das Expressões no 1º Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"150\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:66\",\"eCTS\":\"6\",\"horasContacto\":{\"tP\":\"60\",\"oT\":\"15\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Psicologia da Educação\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"75\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:70\",\"eCTS\":\"3\",\"horasContacto\":{\"tP\":\"30\",\"oT\":\"7\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Investigação em Educação\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"75\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:74\",\"eCTS\":\"3\",\"horasContacto\":{\"tP\":\"30\",\"oT\":\"7\"}}],\"type\":\"semestre\",\"$$hashKey\":\"object:48\"},{\"id\":\"S3\",\"notas\":null,\"perfil\":[],\"semestreDesc\":\"Semestre 1\",\"semestreDescEn\":\"Semester 1\",\"semestreDescEs\":\"Semestre 1\",\"semestreDescFr\":\"Semestre 1\",\"semestreId\":null,\"unidade\":[{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Prática de Ensino Supervisionada no 1º Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"500\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:90\",\"eCTS\":\"20\",\"horasContacto\":{\"s\":\"30\",\"e\":\"270\",\"oT\":\"45\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Seminário de Investigação I\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"50\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:98\",\"eCTS\":\"2\",\"horasContacto\":{\"s\":\"20\",\"oT\":\"10\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Didática da História e Geografia de Portugal no 2º Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"100\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:94\",\"eCTS\":\"4\",\"horasContacto\":{\"tP\":\"35\",\"oT\":\"15\"}},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"Didática do Português no 2º Ciclo do Ensino Básico\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":\"100\",\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:102\",\"eCTS\":\"4\",\"horasContacto\":{\"oT\":\"15\",\"tP\":\"35\"}}],\"type\":\"semestre\",\"$$hashKey\":\"object:78\"},{\"id\":\"S4\",\"notas\":null,\"perfil\":[],\"semestreDesc\":\"Semestre 1\",\"semestreDescEn\":\"Semester 1\",\"semestreDescEs\":\"Semestre 1\",\"semestreDescFr\":\"Semestre 1\",\"semestreId\":null,\"unidade\":[{\"dep\":\"\",\"ects\":\"\",\"nome\":\"\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":0,\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:106\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":0,\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:110\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":0,\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:114\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":0,\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:118\"},{\"dep\":\"\",\"ects\":\"\",\"nome\":\"\",\"nomeEn\":null,\"nomeEs\":null,\"nomeFr\":null,\"obs\":\"\",\"removed\":null,\"siges\":null,\"totalHoras\":0,\"urlFichaCurricular\":\"\",\"urlUnidadeCurricular\":\"\",\"type\":\"unidade\",\"$$hashKey\":\"object:122\"}],\"type\":\"semestre\",\"$$hashKey\":\"object:84\"}],\"siges\":null}"; |
1371 | CursoImpl c = CursoImpl.loadFromJson(json); |
1371 | CursoImpl c = CursoImpl.loadFromJson(json); |
1372 | 1372 | ||
1373 | JAXBContext jc = JAXBContext.newInstance(Curso.class); |
1373 | JAXBContext jc = JAXBContext.newInstance(Curso.class); |
1374 | Marshaller marshaller = jc.createMarshaller(); |
1374 | Marshaller marshaller = jc.createMarshaller(); |
1375 | marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); |
1375 | marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); |
1376 | StringWriter xml = new StringWriter(); |
1376 | StringWriter xml = new StringWriter(); |
1377 | marshaller.marshal(c,xml); |
1377 | marshaller.marshal(c,xml); |
1378 | System.out.println(xml); |
1378 | System.out.println(xml); |
1379 | }*/ |
1379 | }*/ |
1380 | 1380 | ||
1381 | 1381 | ||
1382 | } |
1382 | } |