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.kernel.UserDirectory;
31 import org.splat.manox.Reader;
32 import org.splat.manox.Toolbox;
33 import org.splat.manox.Writer;
35 import org.hibernate.Session;
36 import org.hibernate.Transaction;
37 import org.apache.log4j.Logger;
42 final static Logger logger = Logger.getLogger(Test.class);
44 // ==============================================================================================================================
46 // ==============================================================================================================================
48 public static void main(String[] args) {/* TODO: Create unit tests
49 // --------------------------------------
50 Session session = Database.getSession(); // Single session for multiple operations
51 Transaction transax = session.beginTransaction();
53 ProjectSettingsServiceImpl project = ProjectSettingsServiceImpl.getMe();
54 String path = System.getProperty("user.dir");
56 project.configure(path + "/src/som.xml");
58 catch (Exception error) {
59 logger.fatal("Could not initialize the database, reason:", error);
62 int nargs = args.length;
63 if (nargs > 0) switch (Integer.valueOf(args[0])) {
66 if (!importation_of_users()) return;
70 if (!create_narveos_study()) return;
74 if (!create_tripoli_study()) return;
78 if (!select_user_by_username()) return;
82 if (!select_study_by_state()) return;
86 if (!select_study_by_title()) return;
90 if (!select_study_by_reference()) return;
94 if (!select_study_by_context()) return;
98 if (!select_document_by_reference()) return;
102 if (!select_knowledge_by_context()) return;
106 if (!browse_knowledge()) return;
110 if (!read_wordxml_properties()) return;
114 if (!read_worddoc_properties()) return;
119 private static boolean importation_of_users () {
120 // ----------------------------------------------
122 UserDirectory.importUsers(new File("C:/Users/Daniel/Projets/Internes/SaLoMe/Workspace/org.splat/src/users.xml"));
124 // Print of imported users
125 List<User> result = UserDirectory.selectAllUsers();
126 for (Iterator<User> i=result.iterator(); i.hasNext();) {
127 User auser = i.next();
128 Role[] role = auser.getRoles();
129 String echo = "Role(s) of user " + auser.getIndex() + " (" + auser.toString() + "): " + role[0].getName();
130 for (int j=1; j<role.length; j++) echo = echo + ", " + role[j].getName();
135 catch (Exception error) {
136 logger.info("Reason:", error);
141 private static boolean create_narveos_study () {
142 // ----------------------------------------------
145 User.Properties uprop = new User.Properties();
146 List<User> ulist = UserDirectory.selectUsersWhere(uprop.setOrganizationName("Euriware"));
147 User jb = ulist.get(0); // Manager of the study
148 User pd = ulist.get(1); // Author of specifications
149 User hl = UserDirectory.selectUser("hl"); // Geometry expert
150 User sd = UserDirectory.selectUser("sdd"); // Customer
153 // Creation of the Study object
154 SimpleDateFormat on = new SimpleDateFormat("dd/MM/yyyy");
155 SimpleDateFormat at = new SimpleDateFormat("dd/MM/yyyy HH:mm");
156 Study.Properties sprop = new Study.Properties();
158 Date someday = on.parse("25/01/2010");
159 Study mystudy = Database.createStudy(sprop.setTitle("Caractérisation du béton SERCOTER").setDate(someday).setManager(jb)
160 .setDescription("Cette étude est livrée avec l'application comme exemple pour tester les fonctions de recherche et de navigation."));
163 // Addition of the default scenario
164 Scenario.Properties oprop = new Scenario.Properties();
165 Scenario myscenar = mystudy.addScenario(oprop.setTitle("Scénario 1").setDate(someday));
168 // Definition of the project team
169 mystudy.addContributor(pd);
172 // Addition of documents
173 Step[] ownstep = mystudy.getSteps();
174 Step[] nexstep = myscenar.getSteps();
175 Document.Properties dprop;
176 DocumentType request = Document.selectType("requirements");
177 DocumentType spec = Document.selectType("specification");
178 DocumentType geom = Document.selectType("geometry");
179 DocumentType note = Document.selectType("memorandum");
180 DocumentType delivery = Document.selectType("report"); // Final report of the study
182 // Set of document validation cycles
183 mystudy.setValidationCycle(geom, new ValidationCycle.Properties().setActor(ValidationStep.REVIEW, hl)
184 .setActor(ValidationStep.APPROVAL, jb));
185 // (1) Customer requirements
186 dprop = new Document.Properties();
187 Publication cdc = ownstep[0].createDocument(dprop.setName("Proposition technique")
188 .setExternReference("GCVP-P/09-1629/V1")
189 .setDate(on.parse("08/02/2010"))
193 logger.info("Uploading file \"" + cdc.getSourceFile().getName() + "\" into " + cdc.value().getSaveDirectory().getPath());
194 cdc.saveAs(ProgressState.EXTERN);
196 // (2)(3) General specifications based on (using) Customer requirements
198 Publication specgen = ownstep[0].createDocument(dprop.setName("Spécifications générales")
199 .setDate(on.parse("05/03/2010"))
203 logger.info("Uploading file \"" + specgen.getSourceFile().getName() + "\" into " + specgen.value().getSaveDirectory().getPath());
204 specgen.saveAs(ProgressState.inWORK); // Version 0.1
205 specgen.addDependency(cdc);
208 specgen = ownstep[0].versionDocument(specgen, dprop.setDate(on.parse("12/03/2010"))
209 .setDescription("Ajout de la description du scénario de calcul"));
210 specgen.saveAs(ProgressState.inWORK); // Version 0.2
211 specgen.addDependency(cdc);
213 // (4) Assembly geometry based on (using) General specifications
215 Publication sercoter = nexstep[1].createDocument(dprop.setName("Assemblage SERCOTER")
216 .setDate(on.parse("26/03/2010"))
220 logger.info("Uploading file \"" + sercoter.getSourceFile().getName() + "\" into " + sercoter.value().getSaveDirectory().getPath());
221 sercoter.saveAs(ProgressState.inWORK);
222 sercoter.addDependency(specgen);
224 // (5) Technical note based on (using) General specifications and Assembly geometry
226 Publication report = nexstep[1].createDocument(dprop.setName("Modifications et simplifications retenues")
227 .setDate(on.parse("26/03/2010"))
231 logger.info("Uploading file \"" + report.getSourceFile().getName() + "\" into " + report.value().getSaveDirectory().getPath());
232 report.saveAs(ProgressState.inWORK);
233 report.addDependency(specgen);
234 report.addDependency(sercoter);
235 report.promote(on.parse("26/03/2010"));
237 // (6) New version of General specifications
239 specgen = ownstep[0].versionDocument(specgen, dprop.setDate(on.parse("24/03/2010"))
240 .setDescription("Prise en compte des retours internes"));
241 specgen.saveAs(ProgressState.inDRAFT); // Version 0.3
242 specgen.addDependency(cdc);
244 specgen.review(at.parse("26/03/2010 10:15")); // Promotion to version 1.0
245 specgen.attach("pdf");
246 specgen.approve(at.parse("26/03/2010 16:30")).setComment("Le document peut être envoyé au client.");
247 logger.info("Uploading file \"" + specgen.value().getTitle() + ".pdf\" into " + specgen.value().getSaveDirectory().getPath());
250 Publication result = ownstep[1].createDocument(dprop.setName("Comparaison des résultats")
251 .setDate(on.parse("16/04/2010"))
255 logger.info("Uploading file \"" + result.getSourceFile().getName() + "\" into " + result.value().getSaveDirectory().getPath());
256 result.saveAs(ProgressState.inDRAFT); // Promotes the study to In-Draft
257 result.review (at.parse("19/04/2010 10:15")); // Promotes the study to In-Check
260 // Assignment of simulation contexts
261 SimulationContext.Properties cprop = new SimulationContext.Properties();
262 SimulationContextType customer = SimulationContext.selectType("customer");
263 SimulationContextType product = SimulationContext.selectType("product");
264 SimulationContextType phase = SimulationContext.selectType("phase");
265 SimulationContextType need = SimulationContext.selectType("need");
266 SimulationContextType subject = SimulationContext.selectType("purpose");
267 SimulationContextType physics = SimulationContext.selectType("physic");
268 SimulationContextType object = SimulationContext.selectType("object");
269 SimulationContextType part = SimulationContext.selectType("part");
270 SimulationContextType model = SimulationContext.selectType("model");
271 SimulationContextType element = SimulationContext.selectType("element");
272 SimulationContextType shape = SimulationContext.selectType("shape");
273 SimulationContextType platform = SimulationContext.selectType("platform");
274 SimulationContextType module = SimulationContext.selectType("module");
275 SimulationContextType component = SimulationContext.selectType("component");
277 List<SimulationContext> ihave = mystudy.getFirstStep().getSimulationContext(customer);
278 if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
280 SimulationContext imported = Database.selectSimulationContext(customer, "CEA Cadarache");
281 if (imported == null) {
282 mystudy.addProjectContext(cprop.setType(customer).setValue("CEA Cadarache").setState(ProgressState.APPROVED));
284 mystudy.addProjectContext(imported); // Previously generated
287 ihave = mystudy.getFirstStep().getSimulationContext(product);
288 if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
290 SimulationContext imported = Database.selectSimulationContext(product, "Réacteur RAPSODIE");
291 if (imported == null) {
292 mystudy.addProjectContext(cprop.setType(product).setValue("Réacteur RAPSODIE").setState(ProgressState.APPROVED));
294 mystudy.addProjectContext(imported); // Previously generated
297 mystudy.addProjectContext(cprop.setType(phase).setValue("Démantèlement").setState(ProgressState.APPROVED));
298 mystudy.addProjectContext(cprop.setType(need).setValue("Caractérisation du béton SERCOTER").setState(ProgressState.APPROVED));
299 mystudy.addProjectContext(cprop.setType(subject).setValue("Valider les résultats d'une précédente étude").setState(ProgressState.APPROVED));
300 mystudy.addProjectContext(cprop.setType(physics).setValue("Transport de particules").setState(ProgressState.APPROVED));
301 nexstep[1].addSimulationContext(cprop.setType(object).setValue("Réacteur nucléaire").setState(ProgressState.APPROVED));
302 nexstep[1].addSimulationContext(cprop.setType(part).setValue("Ensemble Bloc réacteur et Enceinte en béton").setState(ProgressState.APPROVED));
303 // nexstep[2].addSimulationContext(cprop.setType(model).setValue("CSG"));
304 nexstep[2].addSimulationContext(cprop.setType(model).setValue("Éléments finis").setState(ProgressState.APPROVED));
305 nexstep[2].addSimulationContext(cprop.setType(element).setValue("Surfacique").setState(ProgressState.APPROVED));
306 nexstep[2].addSimulationContext(cprop.setType(shape).setValue("Triangles").setState(ProgressState.APPROVED));
307 nexstep[4].addSimulationContext(cprop.setType(platform).setValue("NARVEOS V3").setState(ProgressState.APPROVED));
308 nexstep[4].addSimulationContext(cprop.setType(module).setValue("NARMER V2").setState(ProgressState.APPROVED));
309 nexstep[4].addSimulationContext(cprop.setType(component).setValue("VIRTOOLS V5").setState(ProgressState.APPROVED));
311 // Assignment of a knowledge
312 KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
313 KnowledgeElementType practice = KnowledgeElement.selectType("bestpractice");
314 KnowledgeElementType limit = KnowledgeElement.selectType("limitation");
315 KnowledgeElementType improvment = KnowledgeElement.selectType("improvement");
317 .setTitle("Format du modèle géométrique")
318 .setValue("Seul le format 3DXML V5 ou antérieur est supporté.")
319 // .setState(ProgressState.APPROVED)
321 myscenar.addKnowledgeElement(kprop);
322 kprop.setType(practice)
323 .setTitle("Compréhension de l'environnement")
324 .setValue("Avoir une compréhension globale du débit de dose en commençant par effectuer une cartographie.")
325 .setState(ProgressState.APPROVED)
327 myscenar.addKnowledgeElement(kprop);
328 kprop.setType(practice)
329 .setTitle("Calage du modèle radiologique")
330 .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.")
331 .setState(ProgressState.APPROVED)
333 myscenar.addKnowledgeElement(kprop);
334 kprop.setType(practice)
335 .setTitle("Calage du modèle radiologique")
336 .setValue("Toujours faire le premier calcul sans built-up.")
337 .setState(ProgressState.APPROVED)
339 myscenar.addKnowledgeElement(kprop);
341 .setTitle("Effets diffusés indirects")
342 .setValue("L'outil ne tenant pas compte des effets diffusés indirects, faire attention à la géométrie autour des points de calcul.")
343 .setState(ProgressState.APPROVED)
345 myscenar.addKnowledgeElement(kprop);
346 kprop.setType(improvment)
347 .setTitle("Gestion des écrans")
348 .setValue("Mieux gérer les multi-écrans à géométrie cylindrique.")
349 .setState(ProgressState.inCHECK) // Just for testing the approve() function below
351 KnowledgeElement kelm = myscenar.addKnowledgeElement(kprop);
355 mystudy.moveToPublic();
357 logger.info("Study \"" + mystudy.getTitle() + "\" successfully created.");
360 catch (Exception error) {
361 logger.info("Reason:", error);
366 private static boolean create_tripoli_study () {
367 // ----------------------------------------------
368 User plt = UserDirectory.selectUser("sdd");
370 // Creation of the Study object
371 SimpleDateFormat todate = new SimpleDateFormat("dd/MM/yyyy");
372 Study.Properties sprop = new Study.Properties();
374 Date at = todate.parse("03/05/2011");
375 Study mystudy = Database.createStudy(sprop.setTitle("Validation des voies de production de la plate-forme Radioprotection").setDate(at).setManager(plt));
377 // Addition of scenarios
378 Scenario.Properties oprop = new Scenario.Properties();
379 Scenario myscenar = mystudy.addScenario(oprop.setTitle("Scénario Tripoli").setDate(at));
380 mystudy.addScenario(oprop.setTitle("Scénario MCNP").setDate(at));
382 // Addition of documents
383 Step[] ownstep = mystudy.getSteps();
384 Step[] nexstep = myscenar.getSteps();
386 DocumentType request = Document.selectType("requirements");
387 DocumentType spec = Document.selectType("specification");
388 DocumentType geom = Document.selectType("geometry");
389 DocumentType mesh = Document.selectType("model");
390 DocumentType note = Document.selectType("memorandum");
391 DocumentType delivery = Document.selectType("report"); // Final report of the study
392 Document.Properties dprop;
394 dprop = new Document.Properties();
395 Publication cdc = ownstep[0].createDocument(dprop.setName("Cahier des charges")
396 .setDate(todate.parse("03/05/2011"))
400 logger.info("Uploading file \"" + cdc.getSourceFile().getName() + "\" into " + cdc.value().getSaveDirectory().getPath());
401 cdc.saveAs(ProgressState.EXTERN);
403 dprop = new Document.Properties();
404 Publication sgen = ownstep[0].createDocument(dprop.setName("Spécifications générales")
405 .setDate(todate.parse("03/05/2010"))
409 logger.info("Uploading file \"" + sgen.getSourceFile().getName() + "\" into " + sgen.value().getSaveDirectory().getPath());
410 sgen.saveAs(ProgressState.inDRAFT); // Version 0.1
411 sgen.addDependency(cdc);
413 dprop = new Document.Properties();
414 Publication pcc = nexstep[1].createDocument(dprop.setName("Assemblage PCC")
415 .setDate(todate.parse("03/05/2011"))
419 Publication doc = nexstep[1].createDocument(dprop.setName("Description de l'assemblage")
420 .setDate(todate.parse("03/05/2011"))
424 logger.info("Uploading file \"" + pcc.getSourceFile().getName() + "\" into " + pcc.value().getSaveDirectory().getPath());
425 logger.info("Uploading file \"" + doc.getSourceFile().getName() + "\" into " + doc.value().getSaveDirectory().getPath());
426 pcc.saveAs(ProgressState.inDRAFT);
427 doc.saveAs(ProgressState.inCHECK);
429 pcc.review(todate.parse("08/05/2011"));
430 pcc.addDependency(sgen);
431 doc.addDependency(sgen);
432 doc.addDependency(pcc);
435 logger.info("Uploading file \"" + pcc.value().getTitle() + ".gdml\" into " + pcc.value().getSaveDirectory().getPath());
437 dprop = new Document.Properties();
438 Publication csg = nexstep[2].createDocument(dprop.setName("PCC")
439 .setDate(todate.parse("03/05/2011"))
443 logger.info("Uploading file \"" + csg.getSourceFile().getName() + "\" into " + csg.value().getSaveDirectory().getPath());
444 csg.saveAs(ProgressState.inDRAFT);
446 csg.addDependency(pcc);
448 csg.attach("gdml", "sans void space");
449 csg.attach("tri", "avec void space");
451 logger.info("Uploading file \"" + csg.value().getTitle() + ".tri\" into " + csg.value().getSaveDirectory().getPath());
453 Publication result = ownstep[1].createDocument(dprop.setName("Comparaison des résultats")
454 .setDate(todate.parse("17/05/2011"))
458 logger.info("Uploading file \"" + result.getSourceFile().getName() + "\" into " + result.value().getSaveDirectory().getPath());
459 result.saveAs(ProgressState.inWORK); // Version 0.1
460 result.promote(todate.parse("18/05/2011")); // Promotes also the study
462 // Assignment of simulation contexts
463 SimulationContext.Properties cprop = new SimulationContext.Properties();
464 SimulationContextType customer = SimulationContext.selectType("customer");
465 SimulationContextType product = SimulationContext.selectType("product");
466 SimulationContextType phase = SimulationContext.selectType("phase");
467 SimulationContextType need = SimulationContext.selectType("need");
468 SimulationContextType subject = SimulationContext.selectType("purpose");
469 SimulationContextType physics = SimulationContext.selectType("physic");
470 SimulationContextType object = SimulationContext.selectType("object");
471 SimulationContextType part = SimulationContext.selectType("part");
472 SimulationContextType model = SimulationContext.selectType("model");
473 SimulationContextType element = SimulationContext.selectType("element");
474 SimulationContextType shape = SimulationContext.selectType("shape");
475 SimulationContextType platform = SimulationContext.selectType("platform");
476 SimulationContextType module = SimulationContext.selectType("module");
478 List<SimulationContext> ihave = mystudy.getFirstStep().getSimulationContext(customer);
479 if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
481 SimulationContext imported = Database.selectSimulationContext(customer, "Fonction transverse sûreté");
482 if (imported == null) {
483 mystudy.addProjectContext(cprop.setType(customer).setValue("Fonction transverse sûreté").setState(ProgressState.APPROVED));
485 mystudy.addProjectContext(imported); // Not generated from specifications
488 ihave = mystudy.getFirstStep().getSimulationContext(product);
489 if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
491 SimulationContext imported = Database.selectSimulationContext(product, "Laser Mégajoule");
492 if (imported == null) {
493 mystudy.addProjectContext(cprop.setType(product).setValue("Laser Mégajoule").setState(ProgressState.APPROVED));
495 mystudy.addProjectContext(imported); // Not generated from specifications
498 mystudy.addProjectContext(cprop.setType(phase).setValue("Dossier de Validation DSGA/SSPP").setState(ProgressState.APPROVED));
499 mystudy.addProjectContext(cprop.setType(need).setValue("Validation du calcul TRIPOLI4.5 via le PlugIn Pro/E").setState(ProgressState.APPROVED));
500 mystudy.addProjectContext(cprop.setType(subject).setValue("Cartographie neutronique").setState(ProgressState.APPROVED));
501 mystudy.addProjectContext(Database.selectSimulationContext(physics, "Transport de particules"));
502 nexstep[1].addSimulationContext(cprop.setType(object).setValue("Bâtiment LMJ").setState(ProgressState.APPROVED));
503 nexstep[1].addSimulationContext(cprop.setType(part).setValue("Bât. Nord, Sud, Hall d'expériences, Hall lasers").setState(ProgressState.APPROVED));
504 nexstep[2].addSimulationContext(cprop.setType(model).setValue("CSG").setState(ProgressState.APPROVED));
505 nexstep[2].addSimulationContext(cprop.setType(element).setValue("Monte Carlo ").setState(ProgressState.APPROVED));
506 nexstep[2].addSimulationContext(cprop.setType(shape).setValue("Combinatoire volumique").setState(ProgressState.APPROVED));
507 nexstep[4].addSimulationContext(cprop.setType(platform).setValue("SALOME-TRIPOLI V2.04").setState(ProgressState.APPROVED));
508 nexstep[4].addSimulationContext(cprop.setType(module).setValue("TRIPOLI4.5").setState(ProgressState.APPROVED));
510 // Assignment of a knowledge
511 KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
512 KnowledgeElementType practice = KnowledgeElement.selectType("bestpractice");
513 KnowledgeElementType limit = KnowledgeElement.selectType("limitation");
514 KnowledgeElementType improvment = KnowledgeElement.selectType("improvement");
515 kprop.setType(practice)
516 .setTitle("Compréhension des modèles CAO")
517 .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.")
518 .setState(ProgressState.APPROVED)
520 myscenar.addKnowledgeElement(kprop);
521 kprop.setType(practice)
522 .setTitle("Génération du volume complémentaire")
523 .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.")
524 .setState(ProgressState.APPROVED)
526 myscenar.addKnowledgeElement(kprop);
528 .setTitle("Découpage du volume complémentaire")
529 .setValue("Inutile de découper le complémentaire pour le code TRIPOLI4.5. Les performances calculs ne sont pas meilleures.")
530 .setState(ProgressState.APPROVED)
532 myscenar.addKnowledgeElement(kprop);
534 .setTitle("Option de pondération")
535 .setValue("impossible de visualiser sous le viewer OCC les grilles de pondération dans la géométrie (temps d'affichage prohibitif).")
536 .setState(ProgressState.APPROVED)
538 myscenar.addKnowledgeElement(kprop);
539 kprop.setType(improvment)
540 .setTitle("Grille de pondération TRIPOLI4.5")
541 .setValue("Faire évoluer le viewer Ray tracing pour qu'il puisse afficher les grilles de pondération et de maillage.")
542 .setState(ProgressState.APPROVED)
544 myscenar.addKnowledgeElement(kprop);
546 mystudy.moveToPublic();
548 logger.info("Study \"" + mystudy.getTitle() + "\" successfully created.");
551 catch (Exception error) {
552 logger.info("Reason:", error);
557 private static boolean select_user_by_username () {
558 // -------------------------------------------------
561 User user = UserDirectory.selectUser(jbt);
563 logger.info("User " + jbt + " not found.");
565 logger.info("User " + jbt + " found:");
566 logger.info("* " + user.getDisplayName() + ", role \"" + user.getRoleNames() + "\"");
570 catch (Exception e) {
575 private static boolean select_study_by_state () {
576 // -----------------------------------------------
578 User user = UserDirectory.selectUser(dbc);
580 Study.Properties criter1 = new Study.Properties().setState(ProgressState.inPROGRESS);
581 Study.Properties criter2 = new Study.Properties().setState(ProgressState.inWORK).setManager(user);
582 List<Proxy> result = SearchServiceImpl.selectStudiesWhere(criter1, criter2);
583 if (result.size() == 0) {
584 logger.info("No study found.");
586 logger.info("Study(ies) found:");
587 for (int i=0; i<result.size(); i++) {
588 logger.info("* \"" + result.get(i).getTitle() + "\"");
593 catch (Exception e) {
598 private static boolean select_study_by_title () {
599 // -----------------------------------------------
600 String words = "sercoter";
602 Study.Properties criteria = new Study.Properties();
603 List<Proxy> result = SearchServiceImpl.selectStudiesWhere(criteria.setTitle(words));
604 if (result.size() == 0) {
605 logger.info("No study found with a title including \"" + words + "\".");
607 logger.info("Study(ies) found:");
608 for (int i=0; i<result.size(); i++) {
609 logger.info("* \"" + result.get(i).getTitle() + "\"");
614 catch (Exception e) {
619 private static boolean select_study_by_reference () {
620 // ---------------------------------------------------
621 String refid = "PLM110001";
623 Study study = Database.selectStudy(refid);
625 logger.info("Study " + refid + " not found.");
628 logger.info("Study " + refid + ": " + study.getTitle() + ".");
629 display_study(study);
633 catch (Exception e) {
638 private static boolean select_study_by_context () {
639 // -------------------------------------------------
640 SimulationContext.Properties cprop = new SimulationContext.Properties();
641 SimulationContextType ctype = SimulationContext.selectType("Produit");
642 List<SimulationContext> context = Database.selectSimulationContextsWhere(cprop.setType(ctype));
643 for (Iterator<SimulationContext> i=context.iterator(); i.hasNext();) {
644 SimulationContext reactor = i.next();
645 if (reactor.getValue().equals("Réacteur RAPSODIE")) {
647 context = new Vector<SimulationContext>();
648 context.add(reactor);
650 Study.Properties sprop = new Study.Properties();
651 List<Proxy> result = SearchServiceImpl.selectStudiesWhere(sprop.setSimulationContexts(context)
652 .setState(ProgressState.inPROGRESS));
653 if (result.size() == 0) {
654 logger.info("Study on Réacteur RAPSODIE not found.");
657 logger.info("Study on Réacteur RAPSODIE: " + result.get(0).getTitle() + ".");
665 private static boolean select_document_by_reference () {
666 // ------------------------------------------------------
667 String refid = "PLM100001.02";
668 String verid = "2.0.0";
670 Document result = Database.selectDocument(refid, verid);
671 String title = result.getTitle();
672 String refdoc = result.getReference();
673 logger.info("Document " + refdoc + ": " + title + ".");
676 catch (Exception e) {
681 private static boolean select_knowledge_by_context () {
682 // -------------------------------------------------
683 SimulationContext.Properties cprop = new SimulationContext.Properties();
684 SimulationContextType ctype = SimulationContext.selectType("Produit");
685 List<SimulationContext> context = Database.selectSimulationContextsWhere(cprop.setType(ctype));
686 for (Iterator<SimulationContext> i=context.iterator(); i.hasNext();) {
687 SimulationContext reactor = i.next();
688 if (reactor.getValue().equals("Réacteur RAPSODIE")) {
690 context = new Vector<SimulationContext>();
691 context.add(reactor);
693 KnowledgeElementType ktype = KnowledgeElement.selectType("Bonne pratique");
694 KnowledgeElement.Properties sprop = new KnowledgeElement.Properties();
695 List<Proxy> result = SearchServiceImpl.selectKnowledgeElementsWhere(sprop.setSimulationContexts(context)
697 if (result.size() == 0) {
698 logger.info("Study on Réacteur RAPSODIE not found.");
701 logger.info("Study on Réacteur RAPSODIE: " + result.get(0).getTitle() + ".");
709 private static boolean display_study (Study study) {
710 // --------------------------------------------------
712 Step[] mystep = study.getSteps();
713 Scenario[] branch = study.getScenarii();
714 List<Publication> list;
716 for (int j=0; j<mystep.length; j++) {
717 Step step = mystep[j];
718 list = step.getAllDocuments();
719 if (list.size() == 0) continue;
720 logger.info("Step 0." + j + ":");
721 for (Iterator<Publication> k=list.iterator(); k.hasNext();) {
722 Publication doc = k.next();
723 String output = "* " + doc.value().getTitle();
724 List<Publication> exports = doc.getRelations(ConvertsRelation.class);
725 if (exports.size() > 0) {
726 output = output + " et export(s)";
727 for (Iterator<Publication> m=exports.iterator(); m.hasNext(); ) {
728 output = output + " " + m.next().getSourceFile().getName();
734 for (int i=0; i<branch.length; i++) {
735 Scenario scene = branch[i];
736 mystep = scene.getSteps();
737 for (int j=0; j<mystep.length; j++) {
738 Step step = mystep[j];
739 list = step.getAllDocuments();
740 if (list.size() == 0) continue;
741 logger.info("Step " + (i+1) + "." + j + ":");
742 for (Iterator<Publication> k=list.iterator(); k.hasNext();) {
743 Publication doc = k.next();
744 String output = "* " + doc.value().getTitle();
745 List<Publication> exports = doc.getRelations(ConvertsRelation.class);
746 if (exports.size() > 0) {
747 output = output + " et export(s)";
748 for (Iterator<Publication> m=exports.iterator(); m.hasNext(); ) {
749 output = output + " " + m.next().getSourceFile().getName();
758 catch (Exception e) {
763 private static boolean browse_knowledge () {
764 // ------------------------------------------
766 Study study = Database.selectStudy(1);
767 Scenario[] branch = study.getScenarii();
768 List<KnowledgeElementType> types = KnowledgeElement.selectTypesWhere(ProgressState.APPROVED);
770 for (int i=0; i<branch.length; i++) {
771 Scenario scene = branch[i];
772 List<KnowledgeElement> kelms = scene.getAllKnowledgeElements();
773 Iterator<KnowledgeElement> more = kelms.iterator();
774 KnowledgeElement next = null;
775 if (more.hasNext()) next = more.next();
777 for (Iterator<KnowledgeElementType> j=types.iterator(); j.hasNext();) {
778 KnowledgeElementType type = j.next();
779 logger.info(type.getName() + ":");
780 while (next != null && next.getType().equals(type)) {
781 logger.info("* " + next.getTitle() + ": " + next.getValue());
787 catch (Exception e) {
792 private static boolean read_wordxml_properties () {
793 // -------------------------------------------------
794 File template = new File("D:/Atelier/Eclipse/salome/org.splat/src/template.xml");
795 File copy = new File("D:/Atelier/Eclipse/salome/org.splat/src/example.xml");
797 if (copy.exists()) copy.delete();
798 Do.copy(template, copy);
799 Writer credoc = Toolbox.getWriter(copy);
800 if (credoc != null) {
802 // Setting of properties
803 credoc.updateProperty("customer", "CEA Cadarache");
804 credoc.updateProperty("title", "Spécifications générales");
807 // Displaying properties
808 Reader example = Toolbox.getReader(copy);
809 Revision.Format convert = new Revision.Format("V%M.%m");
811 logger.info("Properties of \"" + copy.getName() + "\" document:");
813 value = example.extractProperty("title");
814 logger.info("* Title = " + value);
815 value = example.extractProperty("version");
816 Revision verdoc = convert.parse(value);
817 logger.info("* Version = " + verdoc.toString());
818 value = example.extractProperty("customer");
819 logger.info("* Customer = " + value);
820 value = example.extractText();
821 logger.info("* Text = " + value);
825 catch (Exception e) {
830 private static boolean read_worddoc_properties () {
831 // -------------------------------------------------
832 File file = new File("D:/Atelier/Eclipse/salome/org.splat/src/example.docx");
834 if (!file.exists()) return false;
836 Reader example = Toolbox.getReader(file);
837 logger.info("Properties of \"" + file.getName() + "\" document:");
840 value = example.extractProperty("customer");
841 logger.info("* Customer = " + value);
842 value = example.extractProperty("title");
843 logger.info("* Title = " + value);
844 value = example.extractText();
845 logger.info("* Text = " + value);
848 catch (Exception e) {