4 import java.text.SimpleDateFormat;
6 import java.util.Iterator;
8 import java.util.Vector;
10 import org.splat.som.*;
11 import org.splat.kernel.Do;
12 import org.splat.kernel.UserDirectory;
13 import org.splat.kernel.User;
14 import org.splat.kernel.Role;
15 import org.splat.manox.Reader;
16 import org.splat.manox.Toolbox;
17 import org.splat.manox.Writer;
19 import org.hibernate.Session;
20 import org.hibernate.Transaction;
21 import org.apache.log4j.Logger;
26 final static Logger logger = Logger.getLogger(Test.class);
28 // ==============================================================================================================================
30 // ==============================================================================================================================
32 public static void main(String[] args) {
33 // --------------------------------------
34 Session session = Database.getSession(); // Single session for multiple operations
35 Transaction transax = session.beginTransaction();
37 ProjectSettings project = ProjectSettings.getMe();
38 String path = System.getProperty("user.dir");
40 project.configure(path + "/src/som.xml");
42 catch (Exception error) {
43 logger.fatal("Could not initialize the database, reason:", error);
46 int nargs = args.length;
47 if (nargs > 0) switch (Integer.valueOf(args[0])) {
50 if (!importation_of_users()) return;
54 if (!create_narveos_study()) return;
58 if (!create_tripoli_study()) return;
62 if (!select_user_by_username()) return;
66 if (!select_study_by_state()) return;
70 if (!select_study_by_title()) return;
74 if (!select_study_by_reference()) return;
78 if (!select_study_by_context()) return;
82 if (!select_document_by_reference()) return;
86 if (!select_knowledge_by_context()) return;
90 if (!browse_knowledge()) return;
94 if (!read_wordxml_properties()) return;
98 if (!read_worddoc_properties()) return;
103 private static boolean importation_of_users () {
104 // ----------------------------------------------
106 UserDirectory.importUsers(new File("C:/Users/Daniel/Projets/Internes/SaLoMe/Workspace/org.splat/src/users.xml"));
108 // Print of imported users
109 List<User> result = UserDirectory.selectAllUsers();
110 for (Iterator<User> i=result.iterator(); i.hasNext();) {
111 User auser = i.next();
112 Role[] role = auser.getRoles();
113 String echo = "Role(s) of user " + auser.getIndex() + " (" + auser.toString() + "): " + role[0].getName();
114 for (int j=1; j<role.length; j++) echo = echo + ", " + role[j].getName();
119 catch (Exception error) {
120 logger.info("Reason:", error);
125 private static boolean create_narveos_study () {
126 // ----------------------------------------------
129 User.Properties uprop = new User.Properties();
130 List<User> ulist = UserDirectory.selectUsersWhere(uprop.setOrganizationName("Euriware"));
131 User jb = ulist.get(0); // Manager of the study
132 User pd = ulist.get(1); // Author of specifications
133 User hl = UserDirectory.selectUser("hl"); // Geometry expert
134 User sd = UserDirectory.selectUser("sdd"); // Customer
137 // Creation of the Study object
138 SimpleDateFormat on = new SimpleDateFormat("dd/MM/yyyy");
139 SimpleDateFormat at = new SimpleDateFormat("dd/MM/yyyy HH:mm");
140 Study.Properties sprop = new Study.Properties();
142 Date someday = on.parse("25/01/2010");
143 Study mystudy = Database.createStudy(sprop.setTitle("Caractérisation du béton SERCOTER").setDate(someday).setManager(jb)
144 .setDescription("Cette étude est livrée avec l'application comme exemple pour tester les fonctions de recherche et de navigation."));
147 // Addition of the default scenario
148 Scenario.Properties oprop = new Scenario.Properties();
149 Scenario myscenar = mystudy.addScenario(oprop.setTitle("Scénario 1").setDate(someday));
152 // Definition of the project team
153 mystudy.addContributor(pd);
156 // Addition of documents
157 Step[] ownstep = mystudy.getSteps();
158 Step[] nexstep = myscenar.getSteps();
159 Document.Properties dprop;
160 DocumentType request = Document.selectType("requirements");
161 DocumentType spec = Document.selectType("specification");
162 DocumentType geom = Document.selectType("geometry");
163 DocumentType note = Document.selectType("memorandum");
164 DocumentType delivery = Document.selectType("report"); // Final report of the study
166 // Set of document validation cycles
167 mystudy.setValidationCycle(geom, new ValidationCycle.Properties().setActor(ValidationStep.REVIEW, hl)
168 .setActor(ValidationStep.APPROVAL, jb));
169 // (1) Customer requirements
170 dprop = new Document.Properties();
171 Publication cdc = ownstep[0].createDocument(dprop.setName("Proposition technique")
172 .setExternReference("GCVP-P/09-1629/V1")
173 .setDate(on.parse("08/02/2010"))
177 logger.info("Uploading file \"" + cdc.getSourceFile().getName() + "\" into " + cdc.value().getSaveDirectory().getPath());
178 cdc.saveAs(ProgressState.EXTERN);
180 // (2)(3) General specifications based on (using) Customer requirements
182 Publication specgen = ownstep[0].createDocument(dprop.setName("Spécifications générales")
183 .setDate(on.parse("05/03/2010"))
187 logger.info("Uploading file \"" + specgen.getSourceFile().getName() + "\" into " + specgen.value().getSaveDirectory().getPath());
188 specgen.saveAs(ProgressState.inWORK); // Version 0.1
189 specgen.addDependency(cdc);
192 specgen = ownstep[0].versionDocument(specgen, dprop.setDate(on.parse("12/03/2010"))
193 .setDescription("Ajout de la description du scénario de calcul"));
194 specgen.saveAs(ProgressState.inWORK); // Version 0.2
195 specgen.addDependency(cdc);
197 // (4) Assembly geometry based on (using) General specifications
199 Publication sercoter = nexstep[1].createDocument(dprop.setName("Assemblage SERCOTER")
200 .setDate(on.parse("26/03/2010"))
204 logger.info("Uploading file \"" + sercoter.getSourceFile().getName() + "\" into " + sercoter.value().getSaveDirectory().getPath());
205 sercoter.saveAs(ProgressState.inWORK);
206 sercoter.addDependency(specgen);
208 // (5) Technical note based on (using) General specifications and Assembly geometry
210 Publication report = nexstep[1].createDocument(dprop.setName("Modifications et simplifications retenues")
211 .setDate(on.parse("26/03/2010"))
215 logger.info("Uploading file \"" + report.getSourceFile().getName() + "\" into " + report.value().getSaveDirectory().getPath());
216 report.saveAs(ProgressState.inWORK);
217 report.addDependency(specgen);
218 report.addDependency(sercoter);
219 report.promote(on.parse("26/03/2010"));
221 // (6) New version of General specifications
223 specgen = ownstep[0].versionDocument(specgen, dprop.setDate(on.parse("24/03/2010"))
224 .setDescription("Prise en compte des retours internes"));
225 specgen.saveAs(ProgressState.inDRAFT); // Version 0.3
226 specgen.addDependency(cdc);
228 specgen.review(at.parse("26/03/2010 10:15")); // Promotion to version 1.0
229 specgen.attach("pdf");
230 specgen.approve(at.parse("26/03/2010 16:30")).setComment("Le document peut être envoyé au client.");
231 logger.info("Uploading file \"" + specgen.value().getTitle() + ".pdf\" into " + specgen.value().getSaveDirectory().getPath());
234 Publication result = ownstep[1].createDocument(dprop.setName("Comparaison des résultats")
235 .setDate(on.parse("16/04/2010"))
239 logger.info("Uploading file \"" + result.getSourceFile().getName() + "\" into " + result.value().getSaveDirectory().getPath());
240 result.saveAs(ProgressState.inDRAFT); // Promotes the study to In-Draft
241 result.review (at.parse("19/04/2010 10:15")); // Promotes the study to In-Check
244 // Assignment of simulation contexts
245 SimulationContext.Properties cprop = new SimulationContext.Properties();
246 SimulationContextType customer = SimulationContext.selectType("customer");
247 SimulationContextType product = SimulationContext.selectType("product");
248 SimulationContextType phase = SimulationContext.selectType("phase");
249 SimulationContextType need = SimulationContext.selectType("need");
250 SimulationContextType subject = SimulationContext.selectType("purpose");
251 SimulationContextType physics = SimulationContext.selectType("physic");
252 SimulationContextType object = SimulationContext.selectType("object");
253 SimulationContextType part = SimulationContext.selectType("part");
254 SimulationContextType model = SimulationContext.selectType("model");
255 SimulationContextType element = SimulationContext.selectType("element");
256 SimulationContextType shape = SimulationContext.selectType("shape");
257 SimulationContextType platform = SimulationContext.selectType("platform");
258 SimulationContextType module = SimulationContext.selectType("module");
259 SimulationContextType component = SimulationContext.selectType("component");
261 List<SimulationContext> ihave = mystudy.getFirstStep().getSimulationContext(customer);
262 if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
264 SimulationContext imported = Database.selectSimulationContext(customer, "CEA Cadarache");
265 if (imported == null) {
266 mystudy.addProjectContext(cprop.setType(customer).setValue("CEA Cadarache").setState(ProgressState.APPROVED));
268 mystudy.addProjectContext(imported); // Previously generated
271 ihave = mystudy.getFirstStep().getSimulationContext(product);
272 if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
274 SimulationContext imported = Database.selectSimulationContext(product, "Réacteur RAPSODIE");
275 if (imported == null) {
276 mystudy.addProjectContext(cprop.setType(product).setValue("Réacteur RAPSODIE").setState(ProgressState.APPROVED));
278 mystudy.addProjectContext(imported); // Previously generated
281 mystudy.addProjectContext(cprop.setType(phase).setValue("Démantèlement").setState(ProgressState.APPROVED));
282 mystudy.addProjectContext(cprop.setType(need).setValue("Caractérisation du béton SERCOTER").setState(ProgressState.APPROVED));
283 mystudy.addProjectContext(cprop.setType(subject).setValue("Valider les résultats d'une précédente étude").setState(ProgressState.APPROVED));
284 mystudy.addProjectContext(cprop.setType(physics).setValue("Transport de particules").setState(ProgressState.APPROVED));
285 nexstep[1].addSimulationContext(cprop.setType(object).setValue("Réacteur nucléaire").setState(ProgressState.APPROVED));
286 nexstep[1].addSimulationContext(cprop.setType(part).setValue("Ensemble Bloc réacteur et Enceinte en béton").setState(ProgressState.APPROVED));
287 // nexstep[2].addSimulationContext(cprop.setType(model).setValue("CSG"));
288 nexstep[2].addSimulationContext(cprop.setType(model).setValue("Éléments finis").setState(ProgressState.APPROVED));
289 nexstep[2].addSimulationContext(cprop.setType(element).setValue("Surfacique").setState(ProgressState.APPROVED));
290 nexstep[2].addSimulationContext(cprop.setType(shape).setValue("Triangles").setState(ProgressState.APPROVED));
291 nexstep[4].addSimulationContext(cprop.setType(platform).setValue("NARVEOS V3").setState(ProgressState.APPROVED));
292 nexstep[4].addSimulationContext(cprop.setType(module).setValue("NARMER V2").setState(ProgressState.APPROVED));
293 nexstep[4].addSimulationContext(cprop.setType(component).setValue("VIRTOOLS V5").setState(ProgressState.APPROVED));
295 // Assignment of a knowledge
296 KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
297 KnowledgeElementType practice = KnowledgeElement.selectType("bestpractice");
298 KnowledgeElementType limit = KnowledgeElement.selectType("limitation");
299 KnowledgeElementType improvment = KnowledgeElement.selectType("improvement");
301 .setTitle("Format du modèle géométrique")
302 .setValue("Seul le format 3DXML V5 ou antérieur est supporté.")
303 // .setState(ProgressState.APPROVED)
305 myscenar.addKnowledgeElement(kprop);
306 kprop.setType(practice)
307 .setTitle("Compréhension de l'environnement")
308 .setValue("Avoir une compréhension globale du débit de dose en commençant par effectuer une cartographie.")
309 .setState(ProgressState.APPROVED)
311 myscenar.addKnowledgeElement(kprop);
312 kprop.setType(practice)
313 .setTitle("Calage du modèle radiologique")
314 .setValue("A partir de sources à 1 Bq/m<sup>3</sup>, faire évoluer une source à la fois et vérifier l'impact sur les points de calcul pour connaitre l'influence relative des sources.")
315 .setState(ProgressState.APPROVED)
317 myscenar.addKnowledgeElement(kprop);
318 kprop.setType(practice)
319 .setTitle("Calage du modèle radiologique")
320 .setValue("Toujours faire le premier calcul sans built-up.")
321 .setState(ProgressState.APPROVED)
323 myscenar.addKnowledgeElement(kprop);
325 .setTitle("Effets diffusés indirects")
326 .setValue("L'outil ne tenant pas compte des effets diffusés indirects, faire attention à la géométrie autour des points de calcul.")
327 .setState(ProgressState.APPROVED)
329 myscenar.addKnowledgeElement(kprop);
330 kprop.setType(improvment)
331 .setTitle("Gestion des écrans")
332 .setValue("Mieux gérer les multi-écrans à géométrie cylindrique.")
333 .setState(ProgressState.inCHECK) // Just for testing the approve() function below
335 KnowledgeElement kelm = myscenar.addKnowledgeElement(kprop);
339 mystudy.moveToPublic();
341 logger.info("Study \"" + mystudy.getTitle() + "\" successfully created.");
344 catch (Exception error) {
345 logger.info("Reason:", error);
350 private static boolean create_tripoli_study () {
351 // ----------------------------------------------
352 User plt = UserDirectory.selectUser("sdd");
354 // Creation of the Study object
355 SimpleDateFormat todate = new SimpleDateFormat("dd/MM/yyyy");
356 Study.Properties sprop = new Study.Properties();
358 Date at = todate.parse("03/05/2011");
359 Study mystudy = Database.createStudy(sprop.setTitle("Validation des voies de production de la plate-forme Radioprotection").setDate(at).setManager(plt));
361 // Addition of scenarios
362 Scenario.Properties oprop = new Scenario.Properties();
363 Scenario myscenar = mystudy.addScenario(oprop.setTitle("Scénario Tripoli").setDate(at));
364 mystudy.addScenario(oprop.setTitle("Scénario MCNP").setDate(at));
366 // Addition of documents
367 Step[] ownstep = mystudy.getSteps();
368 Step[] nexstep = myscenar.getSteps();
370 DocumentType request = Document.selectType("requirements");
371 DocumentType spec = Document.selectType("specification");
372 DocumentType geom = Document.selectType("geometry");
373 DocumentType mesh = Document.selectType("model");
374 DocumentType note = Document.selectType("memorandum");
375 DocumentType delivery = Document.selectType("report"); // Final report of the study
376 Document.Properties dprop;
378 dprop = new Document.Properties();
379 Publication cdc = ownstep[0].createDocument(dprop.setName("Cahier des charges")
380 .setDate(todate.parse("03/05/2011"))
384 logger.info("Uploading file \"" + cdc.getSourceFile().getName() + "\" into " + cdc.value().getSaveDirectory().getPath());
385 cdc.saveAs(ProgressState.EXTERN);
387 dprop = new Document.Properties();
388 Publication sgen = ownstep[0].createDocument(dprop.setName("Spécifications générales")
389 .setDate(todate.parse("03/05/2010"))
393 logger.info("Uploading file \"" + sgen.getSourceFile().getName() + "\" into " + sgen.value().getSaveDirectory().getPath());
394 sgen.saveAs(ProgressState.inDRAFT); // Version 0.1
395 sgen.addDependency(cdc);
397 dprop = new Document.Properties();
398 Publication pcc = nexstep[1].createDocument(dprop.setName("Assemblage PCC")
399 .setDate(todate.parse("03/05/2011"))
403 Publication doc = nexstep[1].createDocument(dprop.setName("Description de l'assemblage")
404 .setDate(todate.parse("03/05/2011"))
408 logger.info("Uploading file \"" + pcc.getSourceFile().getName() + "\" into " + pcc.value().getSaveDirectory().getPath());
409 logger.info("Uploading file \"" + doc.getSourceFile().getName() + "\" into " + doc.value().getSaveDirectory().getPath());
410 pcc.saveAs(ProgressState.inDRAFT);
411 doc.saveAs(ProgressState.inCHECK);
413 pcc.review(todate.parse("08/05/2011"));
414 pcc.addDependency(sgen);
415 doc.addDependency(sgen);
416 doc.addDependency(pcc);
419 logger.info("Uploading file \"" + pcc.value().getTitle() + ".gdml\" into " + pcc.value().getSaveDirectory().getPath());
421 dprop = new Document.Properties();
422 Publication csg = nexstep[2].createDocument(dprop.setName("PCC")
423 .setDate(todate.parse("03/05/2011"))
427 logger.info("Uploading file \"" + csg.getSourceFile().getName() + "\" into " + csg.value().getSaveDirectory().getPath());
428 csg.saveAs(ProgressState.inDRAFT);
430 csg.addDependency(pcc);
432 csg.attach("gdml", "sans void space");
433 csg.attach("tri", "avec void space");
435 logger.info("Uploading file \"" + csg.value().getTitle() + ".tri\" into " + csg.value().getSaveDirectory().getPath());
437 Publication result = ownstep[1].createDocument(dprop.setName("Comparaison des résultats")
438 .setDate(todate.parse("17/05/2011"))
442 logger.info("Uploading file \"" + result.getSourceFile().getName() + "\" into " + result.value().getSaveDirectory().getPath());
443 result.saveAs(ProgressState.inWORK); // Version 0.1
444 result.promote(todate.parse("18/05/2011")); // Promotes also the study
446 // Assignment of simulation contexts
447 SimulationContext.Properties cprop = new SimulationContext.Properties();
448 SimulationContextType customer = SimulationContext.selectType("customer");
449 SimulationContextType product = SimulationContext.selectType("product");
450 SimulationContextType phase = SimulationContext.selectType("phase");
451 SimulationContextType need = SimulationContext.selectType("need");
452 SimulationContextType subject = SimulationContext.selectType("purpose");
453 SimulationContextType physics = SimulationContext.selectType("physic");
454 SimulationContextType object = SimulationContext.selectType("object");
455 SimulationContextType part = SimulationContext.selectType("part");
456 SimulationContextType model = SimulationContext.selectType("model");
457 SimulationContextType element = SimulationContext.selectType("element");
458 SimulationContextType shape = SimulationContext.selectType("shape");
459 SimulationContextType platform = SimulationContext.selectType("platform");
460 SimulationContextType module = SimulationContext.selectType("module");
462 List<SimulationContext> ihave = mystudy.getFirstStep().getSimulationContext(customer);
463 if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
465 SimulationContext imported = Database.selectSimulationContext(customer, "Fonction transverse sûreté");
466 if (imported == null) {
467 mystudy.addProjectContext(cprop.setType(customer).setValue("Fonction transverse sûreté").setState(ProgressState.APPROVED));
469 mystudy.addProjectContext(imported); // Not generated from specifications
472 ihave = mystudy.getFirstStep().getSimulationContext(product);
473 if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
475 SimulationContext imported = Database.selectSimulationContext(product, "Laser Mégajoule");
476 if (imported == null) {
477 mystudy.addProjectContext(cprop.setType(product).setValue("Laser Mégajoule").setState(ProgressState.APPROVED));
479 mystudy.addProjectContext(imported); // Not generated from specifications
482 mystudy.addProjectContext(cprop.setType(phase).setValue("Dossier de Validation DSGA/SSPP").setState(ProgressState.APPROVED));
483 mystudy.addProjectContext(cprop.setType(need).setValue("Validation du calcul TRIPOLI4.5 via le PlugIn Pro/E").setState(ProgressState.APPROVED));
484 mystudy.addProjectContext(cprop.setType(subject).setValue("Cartographie neutronique").setState(ProgressState.APPROVED));
485 mystudy.addProjectContext(Database.selectSimulationContext(physics, "Transport de particules"));
486 nexstep[1].addSimulationContext(cprop.setType(object).setValue("Bâtiment LMJ").setState(ProgressState.APPROVED));
487 nexstep[1].addSimulationContext(cprop.setType(part).setValue("Bât. Nord, Sud, Hall d'expériences, Hall lasers").setState(ProgressState.APPROVED));
488 nexstep[2].addSimulationContext(cprop.setType(model).setValue("CSG").setState(ProgressState.APPROVED));
489 nexstep[2].addSimulationContext(cprop.setType(element).setValue("Monte Carlo ").setState(ProgressState.APPROVED));
490 nexstep[2].addSimulationContext(cprop.setType(shape).setValue("Combinatoire volumique").setState(ProgressState.APPROVED));
491 nexstep[4].addSimulationContext(cprop.setType(platform).setValue("SALOME-TRIPOLI V2.04").setState(ProgressState.APPROVED));
492 nexstep[4].addSimulationContext(cprop.setType(module).setValue("TRIPOLI4.5").setState(ProgressState.APPROVED));
494 // Assignment of a knowledge
495 KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
496 KnowledgeElementType practice = KnowledgeElement.selectType("bestpractice");
497 KnowledgeElementType limit = KnowledgeElement.selectType("limitation");
498 KnowledgeElementType improvment = KnowledgeElement.selectType("improvement");
499 kprop.setType(practice)
500 .setTitle("Compréhension des modèles CAO")
501 .setValue("Convertir le modèle CAO par élément (part) et constituer les assemblages sous GDML en vérifiant à chaque étape qu'il n'existe pas d'intersection entre les éléments.")
502 .setState(ProgressState.APPROVED)
504 myscenar.addKnowledgeElement(kprop);
505 kprop.setType(practice)
506 .setTitle("Génération du volume complémentaire")
507 .setValue("Appliquer la génération du volume complémentaire au modèle GDML global de l'installation en sauvegardant le découpage de l'espace complémentaire en tant que volume.")
508 .setState(ProgressState.APPROVED)
510 myscenar.addKnowledgeElement(kprop);
512 .setTitle("Découpage du volume complémentaire")
513 .setValue("Inutile de découper le complémentaire pour le code TRIPOLI4.5. Les performances calculs ne sont pas meilleures.")
514 .setState(ProgressState.APPROVED)
516 myscenar.addKnowledgeElement(kprop);
518 .setTitle("Option de pondération")
519 .setValue("impossible de visualiser sous le viewer OCC les grilles de pondération dans la géométrie (temps d'affichage prohibitif).")
520 .setState(ProgressState.APPROVED)
522 myscenar.addKnowledgeElement(kprop);
523 kprop.setType(improvment)
524 .setTitle("Grille de pondération TRIPOLI4.5")
525 .setValue("Faire évoluer le viewer Ray tracing pour qu'il puisse afficher les grilles de pondération et de maillage.")
526 .setState(ProgressState.APPROVED)
528 myscenar.addKnowledgeElement(kprop);
530 mystudy.moveToPublic();
532 logger.info("Study \"" + mystudy.getTitle() + "\" successfully created.");
535 catch (Exception error) {
536 logger.info("Reason:", error);
541 private static boolean select_user_by_username () {
542 // -------------------------------------------------
545 User user = UserDirectory.selectUser(jbt);
547 logger.info("User " + jbt + " not found.");
549 logger.info("User " + jbt + " found:");
550 logger.info("* " + user.getDisplayName() + ", role \"" + user.getRoleNames() + "\"");
554 catch (Exception e) {
559 private static boolean select_study_by_state () {
560 // -----------------------------------------------
562 User user = UserDirectory.selectUser(dbc);
564 Study.Properties criter1 = new Study.Properties().setState(ProgressState.inPROGRESS);
565 Study.Properties criter2 = new Study.Properties().setState(ProgressState.inWORK).setManager(user);
566 List<Proxy> result = Database.selectStudiesWhere(criter1, criter2);
567 if (result.size() == 0) {
568 logger.info("No study found.");
570 logger.info("Study(ies) found:");
571 for (int i=0; i<result.size(); i++) {
572 logger.info("* \"" + result.get(i).getTitle() + "\"");
577 catch (Exception e) {
582 private static boolean select_study_by_title () {
583 // -----------------------------------------------
584 String words = "sercoter";
586 Study.Properties criteria = new Study.Properties();
587 List<Proxy> result = Database.selectStudiesWhere(criteria.setTitle(words));
588 if (result.size() == 0) {
589 logger.info("No study found with a title including \"" + words + "\".");
591 logger.info("Study(ies) found:");
592 for (int i=0; i<result.size(); i++) {
593 logger.info("* \"" + result.get(i).getTitle() + "\"");
598 catch (Exception e) {
603 private static boolean select_study_by_reference () {
604 // ---------------------------------------------------
605 String refid = "PLM110001";
607 Study study = Database.selectStudy(refid);
609 logger.info("Study " + refid + " not found.");
612 logger.info("Study " + refid + ": " + study.getTitle() + ".");
613 display_study(study);
617 catch (Exception e) {
622 private static boolean select_study_by_context () {
623 // -------------------------------------------------
624 SimulationContext.Properties cprop = new SimulationContext.Properties();
625 SimulationContextType ctype = SimulationContext.selectType("Produit");
626 List<SimulationContext> context = Database.selectSimulationContextsWhere(cprop.setType(ctype));
627 for (Iterator<SimulationContext> i=context.iterator(); i.hasNext();) {
628 SimulationContext reactor = i.next();
629 if (reactor.getValue().equals("Réacteur RAPSODIE")) {
631 context = new Vector<SimulationContext>();
632 context.add(reactor);
634 Study.Properties sprop = new Study.Properties();
635 List<Proxy> result = Database.selectStudiesWhere(sprop.setSimulationContexts(context)
636 .setState(ProgressState.inPROGRESS));
637 if (result.size() == 0) {
638 logger.info("Study on Réacteur RAPSODIE not found.");
641 logger.info("Study on Réacteur RAPSODIE: " + result.get(0).getTitle() + ".");
649 private static boolean select_document_by_reference () {
650 // ------------------------------------------------------
651 String refid = "PLM100001.02";
652 String verid = "2.0.0";
654 Document result = Database.selectDocument(refid, verid);
655 String title = result.getTitle();
656 String refdoc = result.getReference();
657 logger.info("Document " + refdoc + ": " + title + ".");
660 catch (Exception e) {
665 private static boolean select_knowledge_by_context () {
666 // -------------------------------------------------
667 SimulationContext.Properties cprop = new SimulationContext.Properties();
668 SimulationContextType ctype = SimulationContext.selectType("Produit");
669 List<SimulationContext> context = Database.selectSimulationContextsWhere(cprop.setType(ctype));
670 for (Iterator<SimulationContext> i=context.iterator(); i.hasNext();) {
671 SimulationContext reactor = i.next();
672 if (reactor.getValue().equals("Réacteur RAPSODIE")) {
674 context = new Vector<SimulationContext>();
675 context.add(reactor);
677 KnowledgeElementType ktype = KnowledgeElement.selectType("Bonne pratique");
678 KnowledgeElement.Properties sprop = new KnowledgeElement.Properties();
679 List<Proxy> result = Database.selectKnowledgeElementsWhere(sprop.setSimulationContexts(context)
681 if (result.size() == 0) {
682 logger.info("Study on Réacteur RAPSODIE not found.");
685 logger.info("Study on Réacteur RAPSODIE: " + result.get(0).getTitle() + ".");
693 private static boolean display_study (Study study) {
694 // --------------------------------------------------
696 Step[] mystep = study.getSteps();
697 Scenario[] branch = study.getScenarii();
698 List<Publication> list;
700 for (int j=0; j<mystep.length; j++) {
701 Step step = mystep[j];
702 list = step.getAllDocuments();
703 if (list.size() == 0) continue;
704 logger.info("Step 0." + j + ":");
705 for (Iterator<Publication> k=list.iterator(); k.hasNext();) {
706 Publication doc = k.next();
707 String output = "* " + doc.value().getTitle();
708 List<Publication> exports = doc.getRelations(ConvertsRelation.class);
709 if (exports.size() > 0) {
710 output = output + " et export(s)";
711 for (Iterator<Publication> m=exports.iterator(); m.hasNext(); ) {
712 output = output + " " + m.next().getSourceFile().getName();
718 for (int i=0; i<branch.length; i++) {
719 Scenario scene = branch[i];
720 mystep = scene.getSteps();
721 for (int j=0; j<mystep.length; j++) {
722 Step step = mystep[j];
723 list = step.getAllDocuments();
724 if (list.size() == 0) continue;
725 logger.info("Step " + (i+1) + "." + j + ":");
726 for (Iterator<Publication> k=list.iterator(); k.hasNext();) {
727 Publication doc = k.next();
728 String output = "* " + doc.value().getTitle();
729 List<Publication> exports = doc.getRelations(ConvertsRelation.class);
730 if (exports.size() > 0) {
731 output = output + " et export(s)";
732 for (Iterator<Publication> m=exports.iterator(); m.hasNext(); ) {
733 output = output + " " + m.next().getSourceFile().getName();
742 catch (Exception e) {
747 private static boolean browse_knowledge () {
748 // ------------------------------------------
750 Study study = Database.selectStudy(1);
751 Scenario[] branch = study.getScenarii();
752 List<KnowledgeElementType> types = KnowledgeElement.selectTypesWhere(ProgressState.APPROVED);
754 for (int i=0; i<branch.length; i++) {
755 Scenario scene = branch[i];
756 List<KnowledgeElement> kelms = scene.getAllKnowledgeElements();
757 Iterator<KnowledgeElement> more = kelms.iterator();
758 KnowledgeElement next = null;
759 if (more.hasNext()) next = more.next();
761 for (Iterator<KnowledgeElementType> j=types.iterator(); j.hasNext();) {
762 KnowledgeElementType type = j.next();
763 logger.info(type.getName() + ":");
764 while (next != null && next.getType().equals(type)) {
765 logger.info("* " + next.getTitle() + ": " + next.getValue());
771 catch (Exception e) {
776 private static boolean read_wordxml_properties () {
777 // -------------------------------------------------
778 File template = new File("D:/Atelier/Eclipse/salome/org.splat/src/template.xml");
779 File copy = new File("D:/Atelier/Eclipse/salome/org.splat/src/example.xml");
781 if (copy.exists()) copy.delete();
782 Do.copy(template, copy);
783 Writer credoc = Toolbox.getWriter(copy);
784 if (credoc != null) {
786 // Setting of properties
787 credoc.updateProperty("customer", "CEA Cadarache");
788 credoc.updateProperty("title", "Spécifications générales");
791 // Displaying properties
792 Reader example = Toolbox.getReader(copy);
793 Revision.Format convert = new Revision.Format("V%M.%m");
795 logger.info("Properties of \"" + copy.getName() + "\" document:");
797 value = example.extractProperty("title");
798 logger.info("* Title = " + value);
799 value = example.extractProperty("version");
800 Revision verdoc = convert.parse(value);
801 logger.info("* Version = " + verdoc.toString());
802 value = example.extractProperty("customer");
803 logger.info("* Customer = " + value);
804 value = example.extractText();
805 logger.info("* Text = " + value);
809 catch (Exception e) {
814 private static boolean read_worddoc_properties () {
815 // -------------------------------------------------
816 File file = new File("D:/Atelier/Eclipse/salome/org.splat/src/example.docx");
818 if (!file.exists()) return false;
820 Reader example = Toolbox.getReader(file);
821 logger.info("Properties of \"" + file.getName() + "\" document:");
824 value = example.extractProperty("customer");
825 logger.info("* Customer = " + value);
826 value = example.extractProperty("title");
827 logger.info("* Title = " + value);
828 value = example.extractText();
829 logger.info("* Text = " + value);
832 catch (Exception e) {