4 import java.text.SimpleDateFormat;
6 import java.util.Iterator;
8 import java.util.Vector;
10 import org.splat.service.SearchServiceImpl;
11 import org.splat.service.dto.Proxy;
12 import org.splat.service.technical.ProjectSettingsServiceImpl;
13 import org.splat.som.*;
14 import org.splat.dal.bo.kernel.Role;
15 import org.splat.dal.bo.kernel.User;
16 import org.splat.dal.bo.som.ConvertsRelation;
17 import org.splat.dal.bo.som.Document;
18 import org.splat.dal.bo.som.DocumentType;
19 import org.splat.dal.bo.som.KnowledgeElement;
20 import org.splat.dal.bo.som.KnowledgeElementType;
21 import org.splat.dal.bo.som.ProgressState;
22 import org.splat.dal.bo.som.Publication;
23 import org.splat.dal.bo.som.Scenario;
24 import org.splat.dal.bo.som.SimulationContext;
25 import org.splat.dal.bo.som.SimulationContextType;
26 import org.splat.dal.bo.som.Study;
27 import org.splat.dal.bo.som.ValidationCycle;
28 import org.splat.dal.dao.som.Database;
29 import org.splat.kernel.Do;
30 import org.splat.manox.Reader;
31 import org.splat.manox.Toolbox;
32 import org.splat.manox.Writer;
34 import org.hibernate.Session;
35 import org.hibernate.Transaction;
36 import org.apache.log4j.Logger;
41 final static Logger logger = Logger.getLogger(Test.class);
43 // ==============================================================================================================================
45 // ==============================================================================================================================
47 public static void main(String[] args) {/* TODO: Create unit tests
48 // --------------------------------------
49 Session session = Database.getSession(); // Single session for multiple operations
50 Transaction transax = session.beginTransaction();
52 ProjectSettingsServiceImpl project = ProjectSettingsServiceImpl.getMe();
53 String path = System.getProperty("user.dir");
55 project.configure(path + "/src/som.xml");
57 catch (Exception error) {
58 logger.fatal("Could not initialize the database, reason:", error);
61 int nargs = args.length;
62 if (nargs > 0) switch (Integer.valueOf(args[0])) {
65 if (!importation_of_users()) return;
69 if (!create_narveos_study()) return;
73 if (!create_tripoli_study()) return;
77 if (!select_user_by_username()) return;
81 if (!select_study_by_state()) return;
85 if (!select_study_by_title()) return;
89 if (!select_study_by_reference()) return;
93 if (!select_study_by_context()) return;
97 if (!select_document_by_reference()) return;
101 if (!select_knowledge_by_context()) return;
105 if (!browse_knowledge()) return;
109 if (!read_wordxml_properties()) return;
113 if (!read_worddoc_properties()) return;
118 private static boolean importation_of_users () {
119 // ----------------------------------------------
121 UserDirectory.importUsers(new File("C:/Users/Daniel/Projets/Internes/SaLoMe/Workspace/org.splat/src/users.xml"));
123 // Print of imported users
124 List<User> result = UserDirectory.selectAllUsers();
125 for (Iterator<User> i=result.iterator(); i.hasNext();) {
126 User auser = i.next();
127 Role[] role = auser.getRoles();
128 String echo = "Role(s) of user " + auser.getIndex() + " (" + auser.toString() + "): " + role[0].getName();
129 for (int j=1; j<role.length; j++) echo = echo + ", " + role[j].getName();
134 catch (Exception error) {
135 logger.info("Reason:", error);
140 private static boolean create_narveos_study () {
141 // ----------------------------------------------
144 User.Properties uprop = new User.Properties();
145 List<User> ulist = UserDirectory.selectUsersWhere(uprop.setOrganizationName("Euriware"));
146 User jb = ulist.get(0); // Manager of the study
147 User pd = ulist.get(1); // Author of specifications
148 User hl = UserDirectory.selectUser("hl"); // Geometry expert
149 User sd = UserDirectory.selectUser("sdd"); // Customer
152 // Creation of the Study object
153 SimpleDateFormat on = new SimpleDateFormat("dd/MM/yyyy");
154 SimpleDateFormat at = new SimpleDateFormat("dd/MM/yyyy HH:mm");
155 Study.Properties sprop = new Study.Properties();
157 Date someday = on.parse("25/01/2010");
158 Study mystudy = Database.createStudy(sprop.setTitle("Caractérisation du béton SERCOTER").setDate(someday).setManager(jb)
159 .setDescription("Cette étude est livrée avec l'application comme exemple pour tester les fonctions de recherche et de navigation."));
162 // Addition of the default scenario
163 Scenario.Properties oprop = new Scenario.Properties();
164 Scenario myscenar = mystudy.addScenario(oprop.setTitle("Scénario 1").setDate(someday));
167 // Definition of the project team
168 mystudy.addContributor(pd);
171 // Addition of documents
172 Step[] ownstep = mystudy.getSteps();
173 Step[] nexstep = myscenar.getSteps();
174 Document.Properties dprop;
175 DocumentType request = Document.selectType("requirements");
176 DocumentType spec = Document.selectType("specification");
177 DocumentType geom = Document.selectType("geometry");
178 DocumentType note = Document.selectType("memorandum");
179 DocumentType delivery = Document.selectType("report"); // Final report of the study
181 // Set of document validation cycles
182 mystudy.setValidationCycle(geom, new ValidationCycle.Properties().setActor(ValidationStep.REVIEW, hl)
183 .setActor(ValidationStep.APPROVAL, jb));
184 // (1) Customer requirements
185 dprop = new Document.Properties();
186 Publication cdc = ownstep[0].createDocument(dprop.setName("Proposition technique")
187 .setExternReference("GCVP-P/09-1629/V1")
188 .setDate(on.parse("08/02/2010"))
192 logger.info("Uploading file \"" + cdc.getSourceFile().getName() + "\" into " + cdc.value().getSaveDirectory().getPath());
193 cdc.saveAs(ProgressState.EXTERN);
195 // (2)(3) General specifications based on (using) Customer requirements
197 Publication specgen = ownstep[0].createDocument(dprop.setName("Spécifications générales")
198 .setDate(on.parse("05/03/2010"))
202 logger.info("Uploading file \"" + specgen.getSourceFile().getName() + "\" into " + specgen.value().getSaveDirectory().getPath());
203 specgen.saveAs(ProgressState.inWORK); // Version 0.1
204 specgen.addDependency(cdc);
207 specgen = ownstep[0].versionDocument(specgen, dprop.setDate(on.parse("12/03/2010"))
208 .setDescription("Ajout de la description du scénario de calcul"));
209 specgen.saveAs(ProgressState.inWORK); // Version 0.2
210 specgen.addDependency(cdc);
212 // (4) Assembly geometry based on (using) General specifications
214 Publication sercoter = nexstep[1].createDocument(dprop.setName("Assemblage SERCOTER")
215 .setDate(on.parse("26/03/2010"))
219 logger.info("Uploading file \"" + sercoter.getSourceFile().getName() + "\" into " + sercoter.value().getSaveDirectory().getPath());
220 sercoter.saveAs(ProgressState.inWORK);
221 sercoter.addDependency(specgen);
223 // (5) Technical note based on (using) General specifications and Assembly geometry
225 Publication report = nexstep[1].createDocument(dprop.setName("Modifications et simplifications retenues")
226 .setDate(on.parse("26/03/2010"))
230 logger.info("Uploading file \"" + report.getSourceFile().getName() + "\" into " + report.value().getSaveDirectory().getPath());
231 report.saveAs(ProgressState.inWORK);
232 report.addDependency(specgen);
233 report.addDependency(sercoter);
234 report.promote(on.parse("26/03/2010"));
236 // (6) New version of General specifications
238 specgen = ownstep[0].versionDocument(specgen, dprop.setDate(on.parse("24/03/2010"))
239 .setDescription("Prise en compte des retours internes"));
240 specgen.saveAs(ProgressState.inDRAFT); // Version 0.3
241 specgen.addDependency(cdc);
243 specgen.review(at.parse("26/03/2010 10:15")); // Promotion to version 1.0
244 specgen.attach("pdf");
245 specgen.approve(at.parse("26/03/2010 16:30")).setComment("Le document peut être envoyé au client.");
246 logger.info("Uploading file \"" + specgen.value().getTitle() + ".pdf\" into " + specgen.value().getSaveDirectory().getPath());
249 Publication result = ownstep[1].createDocument(dprop.setName("Comparaison des résultats")
250 .setDate(on.parse("16/04/2010"))
254 logger.info("Uploading file \"" + result.getSourceFile().getName() + "\" into " + result.value().getSaveDirectory().getPath());
255 result.saveAs(ProgressState.inDRAFT); // Promotes the study to In-Draft
256 result.review (at.parse("19/04/2010 10:15")); // Promotes the study to In-Check
259 // Assignment of simulation contexts
260 SimulationContext.Properties cprop = new SimulationContext.Properties();
261 SimulationContextType customer = SimulationContext.selectType("customer");
262 SimulationContextType product = SimulationContext.selectType("product");
263 SimulationContextType phase = SimulationContext.selectType("phase");
264 SimulationContextType need = SimulationContext.selectType("need");
265 SimulationContextType subject = SimulationContext.selectType("purpose");
266 SimulationContextType physics = SimulationContext.selectType("physic");
267 SimulationContextType object = SimulationContext.selectType("object");
268 SimulationContextType part = SimulationContext.selectType("part");
269 SimulationContextType model = SimulationContext.selectType("model");
270 SimulationContextType element = SimulationContext.selectType("element");
271 SimulationContextType shape = SimulationContext.selectType("shape");
272 SimulationContextType platform = SimulationContext.selectType("platform");
273 SimulationContextType module = SimulationContext.selectType("module");
274 SimulationContextType component = SimulationContext.selectType("component");
276 List<SimulationContext> ihave = mystudy.getFirstStep().getSimulationContext(customer);
277 if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
279 SimulationContext imported = Database.selectSimulationContext(customer, "CEA Cadarache");
280 if (imported == null) {
281 mystudy.addProjectContext(cprop.setType(customer).setValue("CEA Cadarache").setState(ProgressState.APPROVED));
283 mystudy.addProjectContext(imported); // Previously generated
286 ihave = mystudy.getFirstStep().getSimulationContext(product);
287 if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
289 SimulationContext imported = Database.selectSimulationContext(product, "Réacteur RAPSODIE");
290 if (imported == null) {
291 mystudy.addProjectContext(cprop.setType(product).setValue("Réacteur RAPSODIE").setState(ProgressState.APPROVED));
293 mystudy.addProjectContext(imported); // Previously generated
296 mystudy.addProjectContext(cprop.setType(phase).setValue("Démantèlement").setState(ProgressState.APPROVED));
297 mystudy.addProjectContext(cprop.setType(need).setValue("Caractérisation du béton SERCOTER").setState(ProgressState.APPROVED));
298 mystudy.addProjectContext(cprop.setType(subject).setValue("Valider les résultats d'une précédente étude").setState(ProgressState.APPROVED));
299 mystudy.addProjectContext(cprop.setType(physics).setValue("Transport de particules").setState(ProgressState.APPROVED));
300 nexstep[1].addSimulationContext(cprop.setType(object).setValue("Réacteur nucléaire").setState(ProgressState.APPROVED));
301 nexstep[1].addSimulationContext(cprop.setType(part).setValue("Ensemble Bloc réacteur et Enceinte en béton").setState(ProgressState.APPROVED));
302 // nexstep[2].addSimulationContext(cprop.setType(model).setValue("CSG"));
303 nexstep[2].addSimulationContext(cprop.setType(model).setValue("Éléments finis").setState(ProgressState.APPROVED));
304 nexstep[2].addSimulationContext(cprop.setType(element).setValue("Surfacique").setState(ProgressState.APPROVED));
305 nexstep[2].addSimulationContext(cprop.setType(shape).setValue("Triangles").setState(ProgressState.APPROVED));
306 nexstep[4].addSimulationContext(cprop.setType(platform).setValue("NARVEOS V3").setState(ProgressState.APPROVED));
307 nexstep[4].addSimulationContext(cprop.setType(module).setValue("NARMER V2").setState(ProgressState.APPROVED));
308 nexstep[4].addSimulationContext(cprop.setType(component).setValue("VIRTOOLS V5").setState(ProgressState.APPROVED));
310 // Assignment of a knowledge
311 KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
312 KnowledgeElementType practice = KnowledgeElement.selectType("bestpractice");
313 KnowledgeElementType limit = KnowledgeElement.selectType("limitation");
314 KnowledgeElementType improvment = KnowledgeElement.selectType("improvement");
316 .setTitle("Format du modèle géométrique")
317 .setValue("Seul le format 3DXML V5 ou antérieur est supporté.")
318 // .setState(ProgressState.APPROVED)
320 myscenar.addKnowledgeElement(kprop);
321 kprop.setType(practice)
322 .setTitle("Compréhension de l'environnement")
323 .setValue("Avoir une compréhension globale du débit de dose en commençant par effectuer une cartographie.")
324 .setState(ProgressState.APPROVED)
326 myscenar.addKnowledgeElement(kprop);
327 kprop.setType(practice)
328 .setTitle("Calage du modèle radiologique")
329 .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.")
330 .setState(ProgressState.APPROVED)
332 myscenar.addKnowledgeElement(kprop);
333 kprop.setType(practice)
334 .setTitle("Calage du modèle radiologique")
335 .setValue("Toujours faire le premier calcul sans built-up.")
336 .setState(ProgressState.APPROVED)
338 myscenar.addKnowledgeElement(kprop);
340 .setTitle("Effets diffusés indirects")
341 .setValue("L'outil ne tenant pas compte des effets diffusés indirects, faire attention à la géométrie autour des points de calcul.")
342 .setState(ProgressState.APPROVED)
344 myscenar.addKnowledgeElement(kprop);
345 kprop.setType(improvment)
346 .setTitle("Gestion des écrans")
347 .setValue("Mieux gérer les multi-écrans à géométrie cylindrique.")
348 .setState(ProgressState.inCHECK) // Just for testing the approve() function below
350 KnowledgeElement kelm = myscenar.addKnowledgeElement(kprop);
354 mystudy.moveToPublic();
356 logger.info("Study \"" + mystudy.getTitle() + "\" successfully created.");
359 catch (Exception error) {
360 logger.info("Reason:", error);
365 private static boolean create_tripoli_study () {
366 // ----------------------------------------------
367 User plt = UserDirectory.selectUser("sdd");
369 // Creation of the Study object
370 SimpleDateFormat todate = new SimpleDateFormat("dd/MM/yyyy");
371 Study.Properties sprop = new Study.Properties();
373 Date at = todate.parse("03/05/2011");
374 Study mystudy = Database.createStudy(sprop.setTitle("Validation des voies de production de la plate-forme Radioprotection").setDate(at).setManager(plt));
376 // Addition of scenarios
377 Scenario.Properties oprop = new Scenario.Properties();
378 Scenario myscenar = mystudy.addScenario(oprop.setTitle("Scénario Tripoli").setDate(at));
379 mystudy.addScenario(oprop.setTitle("Scénario MCNP").setDate(at));
381 // Addition of documents
382 Step[] ownstep = mystudy.getSteps();
383 Step[] nexstep = myscenar.getSteps();
385 DocumentType request = Document.selectType("requirements");
386 DocumentType spec = Document.selectType("specification");
387 DocumentType geom = Document.selectType("geometry");
388 DocumentType mesh = Document.selectType("model");
389 DocumentType note = Document.selectType("memorandum");
390 DocumentType delivery = Document.selectType("report"); // Final report of the study
391 Document.Properties dprop;
393 dprop = new Document.Properties();
394 Publication cdc = ownstep[0].createDocument(dprop.setName("Cahier des charges")
395 .setDate(todate.parse("03/05/2011"))
399 logger.info("Uploading file \"" + cdc.getSourceFile().getName() + "\" into " + cdc.value().getSaveDirectory().getPath());
400 cdc.saveAs(ProgressState.EXTERN);
402 dprop = new Document.Properties();
403 Publication sgen = ownstep[0].createDocument(dprop.setName("Spécifications générales")
404 .setDate(todate.parse("03/05/2010"))
408 logger.info("Uploading file \"" + sgen.getSourceFile().getName() + "\" into " + sgen.value().getSaveDirectory().getPath());
409 sgen.saveAs(ProgressState.inDRAFT); // Version 0.1
410 sgen.addDependency(cdc);
412 dprop = new Document.Properties();
413 Publication pcc = nexstep[1].createDocument(dprop.setName("Assemblage PCC")
414 .setDate(todate.parse("03/05/2011"))
418 Publication doc = nexstep[1].createDocument(dprop.setName("Description de l'assemblage")
419 .setDate(todate.parse("03/05/2011"))
423 logger.info("Uploading file \"" + pcc.getSourceFile().getName() + "\" into " + pcc.value().getSaveDirectory().getPath());
424 logger.info("Uploading file \"" + doc.getSourceFile().getName() + "\" into " + doc.value().getSaveDirectory().getPath());
425 pcc.saveAs(ProgressState.inDRAFT);
426 doc.saveAs(ProgressState.inCHECK);
428 pcc.review(todate.parse("08/05/2011"));
429 pcc.addDependency(sgen);
430 doc.addDependency(sgen);
431 doc.addDependency(pcc);
434 logger.info("Uploading file \"" + pcc.value().getTitle() + ".gdml\" into " + pcc.value().getSaveDirectory().getPath());
436 dprop = new Document.Properties();
437 Publication csg = nexstep[2].createDocument(dprop.setName("PCC")
438 .setDate(todate.parse("03/05/2011"))
442 logger.info("Uploading file \"" + csg.getSourceFile().getName() + "\" into " + csg.value().getSaveDirectory().getPath());
443 csg.saveAs(ProgressState.inDRAFT);
445 csg.addDependency(pcc);
447 csg.attach("gdml", "sans void space");
448 csg.attach("tri", "avec void space");
450 logger.info("Uploading file \"" + csg.value().getTitle() + ".tri\" into " + csg.value().getSaveDirectory().getPath());
452 Publication result = ownstep[1].createDocument(dprop.setName("Comparaison des résultats")
453 .setDate(todate.parse("17/05/2011"))
457 logger.info("Uploading file \"" + result.getSourceFile().getName() + "\" into " + result.value().getSaveDirectory().getPath());
458 result.saveAs(ProgressState.inWORK); // Version 0.1
459 result.promote(todate.parse("18/05/2011")); // Promotes also the study
461 // Assignment of simulation contexts
462 SimulationContext.Properties cprop = new SimulationContext.Properties();
463 SimulationContextType customer = SimulationContext.selectType("customer");
464 SimulationContextType product = SimulationContext.selectType("product");
465 SimulationContextType phase = SimulationContext.selectType("phase");
466 SimulationContextType need = SimulationContext.selectType("need");
467 SimulationContextType subject = SimulationContext.selectType("purpose");
468 SimulationContextType physics = SimulationContext.selectType("physic");
469 SimulationContextType object = SimulationContext.selectType("object");
470 SimulationContextType part = SimulationContext.selectType("part");
471 SimulationContextType model = SimulationContext.selectType("model");
472 SimulationContextType element = SimulationContext.selectType("element");
473 SimulationContextType shape = SimulationContext.selectType("shape");
474 SimulationContextType platform = SimulationContext.selectType("platform");
475 SimulationContextType module = SimulationContext.selectType("module");
477 List<SimulationContext> ihave = mystudy.getFirstStep().getSimulationContext(customer);
478 if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
480 SimulationContext imported = Database.selectSimulationContext(customer, "Fonction transverse sûreté");
481 if (imported == null) {
482 mystudy.addProjectContext(cprop.setType(customer).setValue("Fonction transverse sûreté").setState(ProgressState.APPROVED));
484 mystudy.addProjectContext(imported); // Not generated from specifications
487 ihave = mystudy.getFirstStep().getSimulationContext(product);
488 if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
490 SimulationContext imported = Database.selectSimulationContext(product, "Laser Mégajoule");
491 if (imported == null) {
492 mystudy.addProjectContext(cprop.setType(product).setValue("Laser Mégajoule").setState(ProgressState.APPROVED));
494 mystudy.addProjectContext(imported); // Not generated from specifications
497 mystudy.addProjectContext(cprop.setType(phase).setValue("Dossier de Validation DSGA/SSPP").setState(ProgressState.APPROVED));
498 mystudy.addProjectContext(cprop.setType(need).setValue("Validation du calcul TRIPOLI4.5 via le PlugIn Pro/E").setState(ProgressState.APPROVED));
499 mystudy.addProjectContext(cprop.setType(subject).setValue("Cartographie neutronique").setState(ProgressState.APPROVED));
500 mystudy.addProjectContext(Database.selectSimulationContext(physics, "Transport de particules"));
501 nexstep[1].addSimulationContext(cprop.setType(object).setValue("Bâtiment LMJ").setState(ProgressState.APPROVED));
502 nexstep[1].addSimulationContext(cprop.setType(part).setValue("Bât. Nord, Sud, Hall d'expériences, Hall lasers").setState(ProgressState.APPROVED));
503 nexstep[2].addSimulationContext(cprop.setType(model).setValue("CSG").setState(ProgressState.APPROVED));
504 nexstep[2].addSimulationContext(cprop.setType(element).setValue("Monte Carlo ").setState(ProgressState.APPROVED));
505 nexstep[2].addSimulationContext(cprop.setType(shape).setValue("Combinatoire volumique").setState(ProgressState.APPROVED));
506 nexstep[4].addSimulationContext(cprop.setType(platform).setValue("SALOME-TRIPOLI V2.04").setState(ProgressState.APPROVED));
507 nexstep[4].addSimulationContext(cprop.setType(module).setValue("TRIPOLI4.5").setState(ProgressState.APPROVED));
509 // Assignment of a knowledge
510 KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
511 KnowledgeElementType practice = KnowledgeElement.selectType("bestpractice");
512 KnowledgeElementType limit = KnowledgeElement.selectType("limitation");
513 KnowledgeElementType improvment = KnowledgeElement.selectType("improvement");
514 kprop.setType(practice)
515 .setTitle("Compréhension des modèles CAO")
516 .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.")
517 .setState(ProgressState.APPROVED)
519 myscenar.addKnowledgeElement(kprop);
520 kprop.setType(practice)
521 .setTitle("Génération du volume complémentaire")
522 .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.")
523 .setState(ProgressState.APPROVED)
525 myscenar.addKnowledgeElement(kprop);
527 .setTitle("Découpage du volume complémentaire")
528 .setValue("Inutile de découper le complémentaire pour le code TRIPOLI4.5. Les performances calculs ne sont pas meilleures.")
529 .setState(ProgressState.APPROVED)
531 myscenar.addKnowledgeElement(kprop);
533 .setTitle("Option de pondération")
534 .setValue("impossible de visualiser sous le viewer OCC les grilles de pondération dans la géométrie (temps d'affichage prohibitif).")
535 .setState(ProgressState.APPROVED)
537 myscenar.addKnowledgeElement(kprop);
538 kprop.setType(improvment)
539 .setTitle("Grille de pondération TRIPOLI4.5")
540 .setValue("Faire évoluer le viewer Ray tracing pour qu'il puisse afficher les grilles de pondération et de maillage.")
541 .setState(ProgressState.APPROVED)
543 myscenar.addKnowledgeElement(kprop);
545 mystudy.moveToPublic();
547 logger.info("Study \"" + mystudy.getTitle() + "\" successfully created.");
550 catch (Exception error) {
551 logger.info("Reason:", error);
556 private static boolean select_user_by_username () {
557 // -------------------------------------------------
560 User user = UserDirectory.selectUser(jbt);
562 logger.info("User " + jbt + " not found.");
564 logger.info("User " + jbt + " found:");
565 logger.info("* " + user.getDisplayName() + ", role \"" + user.getRoleNames() + "\"");
569 catch (Exception e) {
574 private static boolean select_study_by_state () {
575 // -----------------------------------------------
577 User user = UserDirectory.selectUser(dbc);
579 Study.Properties criter1 = new Study.Properties().setState(ProgressState.inPROGRESS);
580 Study.Properties criter2 = new Study.Properties().setState(ProgressState.inWORK).setManager(user);
581 List<Proxy> result = SearchServiceImpl.selectStudiesWhere(criter1, criter2);
582 if (result.size() == 0) {
583 logger.info("No study found.");
585 logger.info("Study(ies) found:");
586 for (int i=0; i<result.size(); i++) {
587 logger.info("* \"" + result.get(i).getTitle() + "\"");
592 catch (Exception e) {
597 private static boolean select_study_by_title () {
598 // -----------------------------------------------
599 String words = "sercoter";
601 Study.Properties criteria = new Study.Properties();
602 List<Proxy> result = SearchServiceImpl.selectStudiesWhere(criteria.setTitle(words));
603 if (result.size() == 0) {
604 logger.info("No study found with a title including \"" + words + "\".");
606 logger.info("Study(ies) found:");
607 for (int i=0; i<result.size(); i++) {
608 logger.info("* \"" + result.get(i).getTitle() + "\"");
613 catch (Exception e) {
618 private static boolean select_study_by_reference () {
619 // ---------------------------------------------------
620 String refid = "PLM110001";
622 Study study = Database.selectStudy(refid);
624 logger.info("Study " + refid + " not found.");
627 logger.info("Study " + refid + ": " + study.getTitle() + ".");
628 display_study(study);
632 catch (Exception e) {
637 private static boolean select_study_by_context () {
638 // -------------------------------------------------
639 SimulationContext.Properties cprop = new SimulationContext.Properties();
640 SimulationContextType ctype = SimulationContext.selectType("Produit");
641 List<SimulationContext> context = Database.selectSimulationContextsWhere(cprop.setType(ctype));
642 for (Iterator<SimulationContext> i=context.iterator(); i.hasNext();) {
643 SimulationContext reactor = i.next();
644 if (reactor.getValue().equals("Réacteur RAPSODIE")) {
646 context = new Vector<SimulationContext>();
647 context.add(reactor);
649 Study.Properties sprop = new Study.Properties();
650 List<Proxy> result = SearchServiceImpl.selectStudiesWhere(sprop.setSimulationContexts(context)
651 .setState(ProgressState.inPROGRESS));
652 if (result.size() == 0) {
653 logger.info("Study on Réacteur RAPSODIE not found.");
656 logger.info("Study on Réacteur RAPSODIE: " + result.get(0).getTitle() + ".");
664 private static boolean select_document_by_reference () {
665 // ------------------------------------------------------
666 String refid = "PLM100001.02";
667 String verid = "2.0.0";
669 Document result = Database.selectDocument(refid, verid);
670 String title = result.getTitle();
671 String refdoc = result.getReference();
672 logger.info("Document " + refdoc + ": " + title + ".");
675 catch (Exception e) {
680 private static boolean select_knowledge_by_context () {
681 // -------------------------------------------------
682 SimulationContext.Properties cprop = new SimulationContext.Properties();
683 SimulationContextType ctype = SimulationContext.selectType("Produit");
684 List<SimulationContext> context = Database.selectSimulationContextsWhere(cprop.setType(ctype));
685 for (Iterator<SimulationContext> i=context.iterator(); i.hasNext();) {
686 SimulationContext reactor = i.next();
687 if (reactor.getValue().equals("Réacteur RAPSODIE")) {
689 context = new Vector<SimulationContext>();
690 context.add(reactor);
692 KnowledgeElementType ktype = KnowledgeElement.selectType("Bonne pratique");
693 KnowledgeElement.Properties sprop = new KnowledgeElement.Properties();
694 List<Proxy> result = SearchServiceImpl.selectKnowledgeElementsWhere(sprop.setSimulationContexts(context)
696 if (result.size() == 0) {
697 logger.info("Study on Réacteur RAPSODIE not found.");
700 logger.info("Study on Réacteur RAPSODIE: " + result.get(0).getTitle() + ".");
708 private static boolean display_study (Study study) {
709 // --------------------------------------------------
711 Step[] mystep = study.getSteps();
712 Scenario[] branch = study.getScenarii();
713 List<Publication> list;
715 for (int j=0; j<mystep.length; j++) {
716 Step step = mystep[j];
717 list = step.getAllDocuments();
718 if (list.size() == 0) continue;
719 logger.info("Step 0." + j + ":");
720 for (Iterator<Publication> k=list.iterator(); k.hasNext();) {
721 Publication doc = k.next();
722 String output = "* " + doc.value().getTitle();
723 List<Publication> exports = doc.getRelations(ConvertsRelation.class);
724 if (exports.size() > 0) {
725 output = output + " et export(s)";
726 for (Iterator<Publication> m=exports.iterator(); m.hasNext(); ) {
727 output = output + " " + m.next().getSourceFile().getName();
733 for (int i=0; i<branch.length; i++) {
734 Scenario scene = branch[i];
735 mystep = scene.getSteps();
736 for (int j=0; j<mystep.length; j++) {
737 Step step = mystep[j];
738 list = step.getAllDocuments();
739 if (list.size() == 0) continue;
740 logger.info("Step " + (i+1) + "." + j + ":");
741 for (Iterator<Publication> k=list.iterator(); k.hasNext();) {
742 Publication doc = k.next();
743 String output = "* " + doc.value().getTitle();
744 List<Publication> exports = doc.getRelations(ConvertsRelation.class);
745 if (exports.size() > 0) {
746 output = output + " et export(s)";
747 for (Iterator<Publication> m=exports.iterator(); m.hasNext(); ) {
748 output = output + " " + m.next().getSourceFile().getName();
757 catch (Exception e) {
762 private static boolean browse_knowledge () {
763 // ------------------------------------------
765 Study study = Database.selectStudy(1);
766 Scenario[] branch = study.getScenarii();
767 List<KnowledgeElementType> types = KnowledgeElement.selectTypesWhere(ProgressState.APPROVED);
769 for (int i=0; i<branch.length; i++) {
770 Scenario scene = branch[i];
771 List<KnowledgeElement> kelms = scene.getAllKnowledgeElements();
772 Iterator<KnowledgeElement> more = kelms.iterator();
773 KnowledgeElement next = null;
774 if (more.hasNext()) next = more.next();
776 for (Iterator<KnowledgeElementType> j=types.iterator(); j.hasNext();) {
777 KnowledgeElementType type = j.next();
778 logger.info(type.getName() + ":");
779 while (next != null && next.getType().equals(type)) {
780 logger.info("* " + next.getTitle() + ": " + next.getValue());
786 catch (Exception e) {
791 private static boolean read_wordxml_properties () {
792 // -------------------------------------------------
793 File template = new File("D:/Atelier/Eclipse/salome/org.splat/src/template.xml");
794 File copy = new File("D:/Atelier/Eclipse/salome/org.splat/src/example.xml");
796 if (copy.exists()) copy.delete();
797 Do.copy(template, copy);
798 Writer credoc = Toolbox.getWriter(copy);
799 if (credoc != null) {
801 // Setting of properties
802 credoc.updateProperty("customer", "CEA Cadarache");
803 credoc.updateProperty("title", "Spécifications générales");
806 // Displaying properties
807 Reader example = Toolbox.getReader(copy);
808 Revision.Format convert = new Revision.Format("V%M.%m");
810 logger.info("Properties of \"" + copy.getName() + "\" document:");
812 value = example.extractProperty("title");
813 logger.info("* Title = " + value);
814 value = example.extractProperty("version");
815 Revision verdoc = convert.parse(value);
816 logger.info("* Version = " + verdoc.toString());
817 value = example.extractProperty("customer");
818 logger.info("* Customer = " + value);
819 value = example.extractText();
820 logger.info("* Text = " + value);
824 catch (Exception e) {
829 private static boolean read_worddoc_properties () {
830 // -------------------------------------------------
831 File file = new File("D:/Atelier/Eclipse/salome/org.splat/src/example.docx");
833 if (!file.exists()) return false;
835 Reader example = Toolbox.getReader(file);
836 logger.info("Properties of \"" + file.getName() + "\" document:");
839 value = example.extractProperty("customer");
840 logger.info("* Customer = " + value);
841 value = example.extractProperty("title");
842 logger.info("* Title = " + value);
843 value = example.extractText();
844 logger.info("* Text = " + value);
847 catch (Exception e) {