+++ /dev/null
-package test;
-
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.splat.service.SearchServiceImpl;
-import org.splat.service.dto.Proxy;
-import org.splat.service.technical.ProjectSettingsServiceImpl;
-import org.splat.som.*;
-import org.splat.dal.bo.kernel.Role;
-import org.splat.dal.bo.kernel.User;
-import org.splat.dal.bo.som.ConvertsRelation;
-import org.splat.dal.bo.som.Document;
-import org.splat.dal.bo.som.DocumentType;
-import org.splat.dal.bo.som.KnowledgeElement;
-import org.splat.dal.bo.som.KnowledgeElementType;
-import org.splat.dal.bo.som.ProgressState;
-import org.splat.dal.bo.som.Publication;
-import org.splat.dal.bo.som.Scenario;
-import org.splat.dal.bo.som.SimulationContext;
-import org.splat.dal.bo.som.SimulationContextType;
-import org.splat.dal.bo.som.Study;
-import org.splat.dal.bo.som.ValidationCycle;
-import org.splat.dal.dao.som.Database;
-import org.splat.kernel.Do;
-import org.splat.manox.Reader;
-import org.splat.manox.Toolbox;
-import org.splat.manox.Writer;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.apache.log4j.Logger;
-
-
-public class Test {
-
- final static Logger logger = Logger.getLogger(Test.class);
-
-// ==============================================================================================================================
-// Main
-// ==============================================================================================================================
-
- public static void main(String[] args) {/* TODO: Create unit tests
-// --------------------------------------
- Session session = Database.getSession(); // Single session for multiple operations
- Transaction transax = session.beginTransaction();
-
- ProjectSettingsServiceImpl project = ProjectSettingsServiceImpl.getMe();
- String path = System.getProperty("user.dir");
- try {
- project.configure(path + "/src/som.xml");
- }
- catch (Exception error) {
- logger.fatal("Could not initialize the database, reason:", error);
- return;
- }
- int nargs = args.length;
- if (nargs > 0) switch (Integer.valueOf(args[0])) {
-
- case 1:
- if (!importation_of_users()) return;
- break;
-
- case 2:
- if (!create_narveos_study()) return;
- break;
-
- case 3:
- if (!create_tripoli_study()) return;
- break;
-
- case 4:
- if (!select_user_by_username()) return;
- break;
-
- case 5:
- if (!select_study_by_state()) return;
- break;
-
- case 6:
- if (!select_study_by_title()) return;
- break;
-
- case 7:
- if (!select_study_by_reference()) return;
- break;
-
- case 8:
- if (!select_study_by_context()) return;
- break;
-
- case 9:
- if (!select_document_by_reference()) return;
- break;
-
- case 10:
- if (!select_knowledge_by_context()) return;
- break;
-
- case 11:
- if (!browse_knowledge()) return;
- break;
-
- case 12:
- if (!read_wordxml_properties()) return;
- break;
-
- case 13:
- if (!read_worddoc_properties()) return;
- }
- transax.commit();
- }
-
- private static boolean importation_of_users () {
-// ----------------------------------------------
- try {
- UserDirectory.importUsers(new File("C:/Users/Daniel/Projets/Internes/SaLoMe/Workspace/org.splat/src/users.xml"));
-
-// Print of imported users
- List<User> result = UserDirectory.selectAllUsers();
- for (Iterator<User> i=result.iterator(); i.hasNext();) {
- User auser = i.next();
- Role[] role = auser.getRoles();
- String echo = "Role(s) of user " + auser.getIndex() + " (" + auser.toString() + "): " + role[0].getName();
- for (int j=1; j<role.length; j++) echo = echo + ", " + role[j].getName();
- logger.info(echo);
- }
- return true;
- }
- catch (Exception error) {
- logger.info("Reason:", error);
- return false;
- }
- }
-
- private static boolean create_narveos_study () {
-// ----------------------------------------------
- try {
-
- User.Properties uprop = new User.Properties();
- List<User> ulist = UserDirectory.selectUsersWhere(uprop.setOrganizationName("Euriware"));
- User jb = ulist.get(0); // Manager of the study
- User pd = ulist.get(1); // Author of specifications
- User hl = UserDirectory.selectUser("hl"); // Geometry expert
- User sd = UserDirectory.selectUser("sdd"); // Customer
-
-
-// Creation of the Study object
- SimpleDateFormat on = new SimpleDateFormat("dd/MM/yyyy");
- SimpleDateFormat at = new SimpleDateFormat("dd/MM/yyyy HH:mm");
- Study.Properties sprop = new Study.Properties();
-
- Date someday = on.parse("25/01/2010");
- Study mystudy = Database.createStudy(sprop.setTitle("Caractérisation du béton SERCOTER").setDate(someday).setManager(jb)
- .setDescription("Cette étude est livrée avec l'application comme exemple pour tester les fonctions de recherche et de navigation."));
-
-
-// Addition of the default scenario
- Scenario.Properties oprop = new Scenario.Properties();
- Scenario myscenar = mystudy.addScenario(oprop.setTitle("Scénario 1").setDate(someday));
-
-
-// Definition of the project team
- mystudy.addContributor(pd);
-
-
-// Addition of documents
- Step[] ownstep = mystudy.getSteps();
- Step[] nexstep = myscenar.getSteps();
- Document.Properties dprop;
- DocumentType request = Document.selectType("requirements");
- DocumentType spec = Document.selectType("specification");
- DocumentType geom = Document.selectType("geometry");
- DocumentType note = Document.selectType("memorandum");
- DocumentType delivery = Document.selectType("report"); // Final report of the study
-
-// Set of document validation cycles
- mystudy.setValidationCycle(geom, new ValidationCycle.Properties().setActor(ValidationStep.REVIEW, hl)
- .setActor(ValidationStep.APPROVAL, jb));
-// (1) Customer requirements
- dprop = new Document.Properties();
- Publication cdc = ownstep[0].createDocument(dprop.setName("Proposition technique")
- .setExternReference("GCVP-P/09-1629/V1")
- .setDate(on.parse("08/02/2010"))
- .setType(request)
- .setFormat("pdf")
- .setAuthor(sd));
- logger.info("Uploading file \"" + cdc.getSourceFile().getName() + "\" into " + cdc.value().getSaveDirectory().getPath());
- cdc.saveAs(ProgressState.EXTERN);
-
-// (2)(3) General specifications based on (using) Customer requirements
- dprop.clear();
- Publication specgen = ownstep[0].createDocument(dprop.setName("Spécifications générales")
- .setDate(on.parse("05/03/2010"))
- .setType(spec)
- .setFormat("xml")
- .setAuthor(pd));
- logger.info("Uploading file \"" + specgen.getSourceFile().getName() + "\" into " + specgen.value().getSaveDirectory().getPath());
- specgen.saveAs(ProgressState.inWORK); // Version 0.1
- specgen.addDependency(cdc);
-
- dprop.clear();
- specgen = ownstep[0].versionDocument(specgen, dprop.setDate(on.parse("12/03/2010"))
- .setDescription("Ajout de la description du scénario de calcul"));
- specgen.saveAs(ProgressState.inWORK); // Version 0.2
- specgen.addDependency(cdc);
-
-// (4) Assembly geometry based on (using) General specifications
- dprop.clear();
- Publication sercoter = nexstep[1].createDocument(dprop.setName("Assemblage SERCOTER")
- .setDate(on.parse("26/03/2010"))
- .setType(geom)
- .setFormat("sldasm")
- .setAuthor(jb));
- logger.info("Uploading file \"" + sercoter.getSourceFile().getName() + "\" into " + sercoter.value().getSaveDirectory().getPath());
- sercoter.saveAs(ProgressState.inWORK);
- sercoter.addDependency(specgen);
-
-// (5) Technical note based on (using) General specifications and Assembly geometry
- dprop.clear();
- Publication report = nexstep[1].createDocument(dprop.setName("Modifications et simplifications retenues")
- .setDate(on.parse("26/03/2010"))
- .setType(note)
- .setFormat("doc")
- .setAuthor(jb));
- logger.info("Uploading file \"" + report.getSourceFile().getName() + "\" into " + report.value().getSaveDirectory().getPath());
- report.saveAs(ProgressState.inWORK);
- report.addDependency(specgen);
- report.addDependency(sercoter);
- report.promote(on.parse("26/03/2010"));
-
-// (6) New version of General specifications
- dprop.clear();
- specgen = ownstep[0].versionDocument(specgen, dprop.setDate(on.parse("24/03/2010"))
- .setDescription("Prise en compte des retours internes"));
- specgen.saveAs(ProgressState.inDRAFT); // Version 0.3
- specgen.addDependency(cdc);
-
- specgen.review(at.parse("26/03/2010 10:15")); // Promotion to version 1.0
- specgen.attach("pdf");
- specgen.approve(at.parse("26/03/2010 16:30")).setComment("Le document peut être envoyé au client.");
- logger.info("Uploading file \"" + specgen.value().getTitle() + ".pdf\" into " + specgen.value().getSaveDirectory().getPath());
-
-// (7)
- Publication result = ownstep[1].createDocument(dprop.setName("Comparaison des résultats")
- .setDate(on.parse("16/04/2010"))
- .setType(delivery)
- .setFormat("xml")
- .setAuthor(jb));
- logger.info("Uploading file \"" + result.getSourceFile().getName() + "\" into " + result.value().getSaveDirectory().getPath());
- result.saveAs(ProgressState.inDRAFT); // Promotes the study to In-Draft
- result.review (at.parse("19/04/2010 10:15")); // Promotes the study to In-Check
-
-
-// Assignment of simulation contexts
- SimulationContext.Properties cprop = new SimulationContext.Properties();
- SimulationContextType customer = SimulationContext.selectType("customer");
- SimulationContextType product = SimulationContext.selectType("product");
- SimulationContextType phase = SimulationContext.selectType("phase");
- SimulationContextType need = SimulationContext.selectType("need");
- SimulationContextType subject = SimulationContext.selectType("purpose");
- SimulationContextType physics = SimulationContext.selectType("physic");
- SimulationContextType object = SimulationContext.selectType("object");
- SimulationContextType part = SimulationContext.selectType("part");
- SimulationContextType model = SimulationContext.selectType("model");
- SimulationContextType element = SimulationContext.selectType("element");
- SimulationContextType shape = SimulationContext.selectType("shape");
- SimulationContextType platform = SimulationContext.selectType("platform");
- SimulationContextType module = SimulationContext.selectType("module");
- SimulationContextType component = SimulationContext.selectType("component");
-
- List<SimulationContext> ihave = mystudy.getFirstStep().getSimulationContext(customer);
- if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
- else {
- SimulationContext imported = Database.selectSimulationContext(customer, "CEA Cadarache");
- if (imported == null) {
- mystudy.addProjectContext(cprop.setType(customer).setValue("CEA Cadarache").setState(ProgressState.APPROVED));
- } else {
- mystudy.addProjectContext(imported); // Previously generated
- }
- }
- ihave = mystudy.getFirstStep().getSimulationContext(product);
- if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
- else {
- SimulationContext imported = Database.selectSimulationContext(product, "Réacteur RAPSODIE");
- if (imported == null) {
- mystudy.addProjectContext(cprop.setType(product).setValue("Réacteur RAPSODIE").setState(ProgressState.APPROVED));
- } else {
- mystudy.addProjectContext(imported); // Previously generated
- }
- }
- mystudy.addProjectContext(cprop.setType(phase).setValue("Démantèlement").setState(ProgressState.APPROVED));
- mystudy.addProjectContext(cprop.setType(need).setValue("Caractérisation du béton SERCOTER").setState(ProgressState.APPROVED));
- mystudy.addProjectContext(cprop.setType(subject).setValue("Valider les résultats d'une précédente étude").setState(ProgressState.APPROVED));
- mystudy.addProjectContext(cprop.setType(physics).setValue("Transport de particules").setState(ProgressState.APPROVED));
- nexstep[1].addSimulationContext(cprop.setType(object).setValue("Réacteur nucléaire").setState(ProgressState.APPROVED));
- nexstep[1].addSimulationContext(cprop.setType(part).setValue("Ensemble Bloc réacteur et Enceinte en béton").setState(ProgressState.APPROVED));
-// nexstep[2].addSimulationContext(cprop.setType(model).setValue("CSG"));
- nexstep[2].addSimulationContext(cprop.setType(model).setValue("Éléments finis").setState(ProgressState.APPROVED));
- nexstep[2].addSimulationContext(cprop.setType(element).setValue("Surfacique").setState(ProgressState.APPROVED));
- nexstep[2].addSimulationContext(cprop.setType(shape).setValue("Triangles").setState(ProgressState.APPROVED));
- nexstep[4].addSimulationContext(cprop.setType(platform).setValue("NARVEOS V3").setState(ProgressState.APPROVED));
- nexstep[4].addSimulationContext(cprop.setType(module).setValue("NARMER V2").setState(ProgressState.APPROVED));
- nexstep[4].addSimulationContext(cprop.setType(component).setValue("VIRTOOLS V5").setState(ProgressState.APPROVED));
-
-// Assignment of a knowledge
- KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
- KnowledgeElementType practice = KnowledgeElement.selectType("bestpractice");
- KnowledgeElementType limit = KnowledgeElement.selectType("limitation");
- KnowledgeElementType improvment = KnowledgeElement.selectType("improvement");
- kprop.setType(limit)
- .setTitle("Format du modèle géométrique")
- .setValue("Seul le format 3DXML V5 ou antérieur est supporté.")
-// .setState(ProgressState.APPROVED)
- .setAuthor(jb);
- myscenar.addKnowledgeElement(kprop);
- kprop.setType(practice)
- .setTitle("Compréhension de l'environnement")
- .setValue("Avoir une compréhension globale du débit de dose en commençant par effectuer une cartographie.")
- .setState(ProgressState.APPROVED)
- .setAuthor(jb);
- myscenar.addKnowledgeElement(kprop);
- kprop.setType(practice)
- .setTitle("Calage du modèle radiologique")
- .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.")
- .setState(ProgressState.APPROVED)
- .setAuthor(jb);
- myscenar.addKnowledgeElement(kprop);
- kprop.setType(practice)
- .setTitle("Calage du modèle radiologique")
- .setValue("Toujours faire le premier calcul sans built-up.")
- .setState(ProgressState.APPROVED)
- .setAuthor(jb);
- myscenar.addKnowledgeElement(kprop);
- kprop.setType(limit)
- .setTitle("Effets diffusés indirects")
- .setValue("L'outil ne tenant pas compte des effets diffusés indirects, faire attention à la géométrie autour des points de calcul.")
- .setState(ProgressState.APPROVED)
- .setAuthor(jb);
- myscenar.addKnowledgeElement(kprop);
- kprop.setType(improvment)
- .setTitle("Gestion des écrans")
- .setValue("Mieux gérer les multi-écrans à géométrie cylindrique.")
- .setState(ProgressState.inCHECK) // Just for testing the approve() function below
- .setAuthor(jb);
- KnowledgeElement kelm = myscenar.addKnowledgeElement(kprop);
-
- kelm.approve();
-
- mystudy.moveToPublic();
-
- logger.info("Study \"" + mystudy.getTitle() + "\" successfully created.");
- return true;
- }
- catch (Exception error) {
- logger.info("Reason:", error);
- return false;
- }
- }
-
- private static boolean create_tripoli_study () {
-// ----------------------------------------------
- User plt = UserDirectory.selectUser("sdd");
- try {
-// Creation of the Study object
- SimpleDateFormat todate = new SimpleDateFormat("dd/MM/yyyy");
- Study.Properties sprop = new Study.Properties();
-
- Date at = todate.parse("03/05/2011");
- Study mystudy = Database.createStudy(sprop.setTitle("Validation des voies de production de la plate-forme Radioprotection").setDate(at).setManager(plt));
-
-// Addition of scenarios
- Scenario.Properties oprop = new Scenario.Properties();
- Scenario myscenar = mystudy.addScenario(oprop.setTitle("Scénario Tripoli").setDate(at));
- mystudy.addScenario(oprop.setTitle("Scénario MCNP").setDate(at));
-
-// Addition of documents
- Step[] ownstep = mystudy.getSteps();
- Step[] nexstep = myscenar.getSteps();
-
- DocumentType request = Document.selectType("requirements");
- DocumentType spec = Document.selectType("specification");
- DocumentType geom = Document.selectType("geometry");
- DocumentType mesh = Document.selectType("model");
- DocumentType note = Document.selectType("memorandum");
- DocumentType delivery = Document.selectType("report"); // Final report of the study
- Document.Properties dprop;
-
- dprop = new Document.Properties();
- Publication cdc = ownstep[0].createDocument(dprop.setName("Cahier des charges")
- .setDate(todate.parse("03/05/2011"))
- .setType(request)
- .setFormat("pdf")
- .setAuthor(plt));
- logger.info("Uploading file \"" + cdc.getSourceFile().getName() + "\" into " + cdc.value().getSaveDirectory().getPath());
- cdc.saveAs(ProgressState.EXTERN);
-
- dprop = new Document.Properties();
- Publication sgen = ownstep[0].createDocument(dprop.setName("Spécifications générales")
- .setDate(todate.parse("03/05/2010"))
- .setType(spec)
- .setFormat("xml")
- .setAuthor(plt));
- logger.info("Uploading file \"" + sgen.getSourceFile().getName() + "\" into " + sgen.value().getSaveDirectory().getPath());
- sgen.saveAs(ProgressState.inDRAFT); // Version 0.1
- sgen.addDependency(cdc);
-
- dprop = new Document.Properties();
- Publication pcc = nexstep[1].createDocument(dprop.setName("Assemblage PCC")
- .setDate(todate.parse("03/05/2011"))
- .setType(geom)
- .setFormat("ProE")
- .setAuthor(plt));
- Publication doc = nexstep[1].createDocument(dprop.setName("Description de l'assemblage")
- .setDate(todate.parse("03/05/2011"))
- .setType(note)
- .setFormat("doc")
- .setAuthor(plt));
- logger.info("Uploading file \"" + pcc.getSourceFile().getName() + "\" into " + pcc.value().getSaveDirectory().getPath());
- logger.info("Uploading file \"" + doc.getSourceFile().getName() + "\" into " + doc.value().getSaveDirectory().getPath());
- pcc.saveAs(ProgressState.inDRAFT);
- doc.saveAs(ProgressState.inCHECK);
-
- pcc.review(todate.parse("08/05/2011"));
- pcc.addDependency(sgen);
- doc.addDependency(sgen);
- doc.addDependency(pcc);
-
- pcc.attach("gdml");
- logger.info("Uploading file \"" + pcc.value().getTitle() + ".gdml\" into " + pcc.value().getSaveDirectory().getPath());
-
- dprop = new Document.Properties();
- Publication csg = nexstep[2].createDocument(dprop.setName("PCC")
- .setDate(todate.parse("03/05/2011"))
- .setType(mesh)
- .setFormat("hdf")
- .setAuthor(plt));
- logger.info("Uploading file \"" + csg.getSourceFile().getName() + "\" into " + csg.value().getSaveDirectory().getPath());
- csg.saveAs(ProgressState.inDRAFT);
-
- csg.addDependency(pcc);
-
- csg.attach("gdml", "sans void space");
- csg.attach("tri", "avec void space");
- csg.attach("pdf");
- logger.info("Uploading file \"" + csg.value().getTitle() + ".tri\" into " + csg.value().getSaveDirectory().getPath());
-
- Publication result = ownstep[1].createDocument(dprop.setName("Comparaison des résultats")
- .setDate(todate.parse("17/05/2011"))
- .setType(delivery)
- .setFormat("xml")
- .setAuthor(plt));
- logger.info("Uploading file \"" + result.getSourceFile().getName() + "\" into " + result.value().getSaveDirectory().getPath());
- result.saveAs(ProgressState.inWORK); // Version 0.1
- result.promote(todate.parse("18/05/2011")); // Promotes also the study
-
-// Assignment of simulation contexts
- SimulationContext.Properties cprop = new SimulationContext.Properties();
- SimulationContextType customer = SimulationContext.selectType("customer");
- SimulationContextType product = SimulationContext.selectType("product");
- SimulationContextType phase = SimulationContext.selectType("phase");
- SimulationContextType need = SimulationContext.selectType("need");
- SimulationContextType subject = SimulationContext.selectType("purpose");
- SimulationContextType physics = SimulationContext.selectType("physic");
- SimulationContextType object = SimulationContext.selectType("object");
- SimulationContextType part = SimulationContext.selectType("part");
- SimulationContextType model = SimulationContext.selectType("model");
- SimulationContextType element = SimulationContext.selectType("element");
- SimulationContextType shape = SimulationContext.selectType("shape");
- SimulationContextType platform = SimulationContext.selectType("platform");
- SimulationContextType module = SimulationContext.selectType("module");
-
- List<SimulationContext> ihave = mystudy.getFirstStep().getSimulationContext(customer);
- if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
- else {
- SimulationContext imported = Database.selectSimulationContext(customer, "Fonction transverse sûreté");
- if (imported == null) {
- mystudy.addProjectContext(cprop.setType(customer).setValue("Fonction transverse sûreté").setState(ProgressState.APPROVED));
- } else {
- mystudy.addProjectContext(imported); // Not generated from specifications
- }
- }
- ihave = mystudy.getFirstStep().getSimulationContext(product);
- if (ihave.size() > 0) ihave.get(0).approve(); // Generated from specifications
- else {
- SimulationContext imported = Database.selectSimulationContext(product, "Laser Mégajoule");
- if (imported == null) {
- mystudy.addProjectContext(cprop.setType(product).setValue("Laser Mégajoule").setState(ProgressState.APPROVED));
- } else {
- mystudy.addProjectContext(imported); // Not generated from specifications
- }
- }
- mystudy.addProjectContext(cprop.setType(phase).setValue("Dossier de Validation DSGA/SSPP").setState(ProgressState.APPROVED));
- mystudy.addProjectContext(cprop.setType(need).setValue("Validation du calcul TRIPOLI4.5 via le PlugIn Pro/E").setState(ProgressState.APPROVED));
- mystudy.addProjectContext(cprop.setType(subject).setValue("Cartographie neutronique").setState(ProgressState.APPROVED));
- mystudy.addProjectContext(Database.selectSimulationContext(physics, "Transport de particules"));
- nexstep[1].addSimulationContext(cprop.setType(object).setValue("Bâtiment LMJ").setState(ProgressState.APPROVED));
- nexstep[1].addSimulationContext(cprop.setType(part).setValue("Bât. Nord, Sud, Hall d'expériences, Hall lasers").setState(ProgressState.APPROVED));
- nexstep[2].addSimulationContext(cprop.setType(model).setValue("CSG").setState(ProgressState.APPROVED));
- nexstep[2].addSimulationContext(cprop.setType(element).setValue("Monte Carlo ").setState(ProgressState.APPROVED));
- nexstep[2].addSimulationContext(cprop.setType(shape).setValue("Combinatoire volumique").setState(ProgressState.APPROVED));
- nexstep[4].addSimulationContext(cprop.setType(platform).setValue("SALOME-TRIPOLI V2.04").setState(ProgressState.APPROVED));
- nexstep[4].addSimulationContext(cprop.setType(module).setValue("TRIPOLI4.5").setState(ProgressState.APPROVED));
-
-// Assignment of a knowledge
- KnowledgeElement.Properties kprop = new KnowledgeElement.Properties();
- KnowledgeElementType practice = KnowledgeElement.selectType("bestpractice");
- KnowledgeElementType limit = KnowledgeElement.selectType("limitation");
- KnowledgeElementType improvment = KnowledgeElement.selectType("improvement");
- kprop.setType(practice)
- .setTitle("Compréhension des modèles CAO")
- .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.")
- .setState(ProgressState.APPROVED)
- .setAuthor(plt);
- myscenar.addKnowledgeElement(kprop);
- kprop.setType(practice)
- .setTitle("Génération du volume complémentaire")
- .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.")
- .setState(ProgressState.APPROVED)
- .setAuthor(plt);
- myscenar.addKnowledgeElement(kprop);
- kprop.setType(limit)
- .setTitle("Découpage du volume complémentaire")
- .setValue("Inutile de découper le complémentaire pour le code TRIPOLI4.5. Les performances calculs ne sont pas meilleures.")
- .setState(ProgressState.APPROVED)
- .setAuthor(plt);
- myscenar.addKnowledgeElement(kprop);
- kprop.setType(limit)
- .setTitle("Option de pondération")
- .setValue("impossible de visualiser sous le viewer OCC les grilles de pondération dans la géométrie (temps d'affichage prohibitif).")
- .setState(ProgressState.APPROVED)
- .setAuthor(plt);
- myscenar.addKnowledgeElement(kprop);
- kprop.setType(improvment)
- .setTitle("Grille de pondération TRIPOLI4.5")
- .setValue("Faire évoluer le viewer Ray tracing pour qu'il puisse afficher les grilles de pondération et de maillage.")
- .setState(ProgressState.APPROVED)
- .setAuthor(plt);
- myscenar.addKnowledgeElement(kprop);
-
- mystudy.moveToPublic();
-
- logger.info("Study \"" + mystudy.getTitle() + "\" successfully created.");
- return true;
- }
- catch (Exception error) {
- logger.info("Reason:", error);
- return false;
- }
- }
-
- private static boolean select_user_by_username () {
-// -------------------------------------------------
- String jbt = "jbt";
- try {
- User user = UserDirectory.selectUser(jbt);
- if (user == null) {
- logger.info("User " + jbt + " not found.");
- } else {
- logger.info("User " + jbt + " found:");
- logger.info("* " + user.getDisplayName() + ", role \"" + user.getRoleNames() + "\"");
- }
- return true;
- }
- catch (Exception e) {
- return false;
- }
- }
-
- private static boolean select_study_by_state () {
-// -----------------------------------------------
- String dbc = "jbt";
- User user = UserDirectory.selectUser(dbc);
- try {
- Study.Properties criter1 = new Study.Properties().setState(ProgressState.inPROGRESS);
- Study.Properties criter2 = new Study.Properties().setState(ProgressState.inWORK).setManager(user);
- List<Proxy> result = SearchServiceImpl.selectStudiesWhere(criter1, criter2);
- if (result.size() == 0) {
- logger.info("No study found.");
- } else {
- logger.info("Study(ies) found:");
- for (int i=0; i<result.size(); i++) {
- logger.info("* \"" + result.get(i).getTitle() + "\"");
- }
- }
- return true;
- }
- catch (Exception e) {
- return false;
- }
- }
-
- private static boolean select_study_by_title () {
-// -----------------------------------------------
- String words = "sercoter";
- try {
- Study.Properties criteria = new Study.Properties();
- List<Proxy> result = SearchServiceImpl.selectStudiesWhere(criteria.setTitle(words));
- if (result.size() == 0) {
- logger.info("No study found with a title including \"" + words + "\".");
- } else {
- logger.info("Study(ies) found:");
- for (int i=0; i<result.size(); i++) {
- logger.info("* \"" + result.get(i).getTitle() + "\"");
- }
- }
- return true;
- }
- catch (Exception e) {
- return false;
- }
- }
-
- private static boolean select_study_by_reference () {
-// ---------------------------------------------------
- String refid = "PLM110001";
- try {
- Study study = Database.selectStudy(refid);
- if (study == null) {
- logger.info("Study " + refid + " not found.");
- return false;
- } else {
- logger.info("Study " + refid + ": " + study.getTitle() + ".");
- display_study(study);
- return true;
- }
- }
- catch (Exception e) {
- return false;
- }
- }
-
- private static boolean select_study_by_context () {
-// -------------------------------------------------
- SimulationContext.Properties cprop = new SimulationContext.Properties();
- SimulationContextType ctype = SimulationContext.selectType("Produit");
- List<SimulationContext> context = Database.selectSimulationContextsWhere(cprop.setType(ctype));
- for (Iterator<SimulationContext> i=context.iterator(); i.hasNext();) {
- SimulationContext reactor = i.next();
- if (reactor.getValue().equals("Réacteur RAPSODIE")) {
-
- context = new Vector<SimulationContext>();
- context.add(reactor);
-
- Study.Properties sprop = new Study.Properties();
- List<Proxy> result = SearchServiceImpl.selectStudiesWhere(sprop.setSimulationContexts(context)
- .setState(ProgressState.inPROGRESS));
- if (result.size() == 0) {
- logger.info("Study on Réacteur RAPSODIE not found.");
- return false;
- } else {
- logger.info("Study on Réacteur RAPSODIE: " + result.get(0).getTitle() + ".");
- return true;
- }
- }
- }
- return false;
- }
-
- private static boolean select_document_by_reference () {
-// ------------------------------------------------------
- String refid = "PLM100001.02";
- String verid = "2.0.0";
- try {
- Document result = Database.selectDocument(refid, verid);
- String title = result.getTitle();
- String refdoc = result.getReference();
- logger.info("Document " + refdoc + ": " + title + ".");
- return true;
- }
- catch (Exception e) {
- return false;
- }
- }
-
- private static boolean select_knowledge_by_context () {
-// -------------------------------------------------
- SimulationContext.Properties cprop = new SimulationContext.Properties();
- SimulationContextType ctype = SimulationContext.selectType("Produit");
- List<SimulationContext> context = Database.selectSimulationContextsWhere(cprop.setType(ctype));
- for (Iterator<SimulationContext> i=context.iterator(); i.hasNext();) {
- SimulationContext reactor = i.next();
- if (reactor.getValue().equals("Réacteur RAPSODIE")) {
-
- context = new Vector<SimulationContext>();
- context.add(reactor);
-
- KnowledgeElementType ktype = KnowledgeElement.selectType("Bonne pratique");
- KnowledgeElement.Properties sprop = new KnowledgeElement.Properties();
- List<Proxy> result = SearchServiceImpl.selectKnowledgeElementsWhere(sprop.setSimulationContexts(context)
- .setType(ktype));
- if (result.size() == 0) {
- logger.info("Study on Réacteur RAPSODIE not found.");
- return false;
- } else {
- logger.info("Study on Réacteur RAPSODIE: " + result.get(0).getTitle() + ".");
- return true;
- }
- }
- }
- return false;
- }
-
- private static boolean display_study (Study study) {
-// --------------------------------------------------
- try {
- Step[] mystep = study.getSteps();
- Scenario[] branch = study.getScenarii();
- List<Publication> list;
-
- for (int j=0; j<mystep.length; j++) {
- Step step = mystep[j];
- list = step.getAllDocuments();
- if (list.size() == 0) continue;
- logger.info("Step 0." + j + ":");
- for (Iterator<Publication> k=list.iterator(); k.hasNext();) {
- Publication doc = k.next();
- String output = "* " + doc.value().getTitle();
- List<Publication> exports = doc.getRelations(ConvertsRelation.class);
- if (exports.size() > 0) {
- output = output + " et export(s)";
- for (Iterator<Publication> m=exports.iterator(); m.hasNext(); ) {
- output = output + " " + m.next().getSourceFile().getName();
- }
- }
- logger.info(output);
- }
- }
- for (int i=0; i<branch.length; i++) {
- Scenario scene = branch[i];
- mystep = scene.getSteps();
- for (int j=0; j<mystep.length; j++) {
- Step step = mystep[j];
- list = step.getAllDocuments();
- if (list.size() == 0) continue;
- logger.info("Step " + (i+1) + "." + j + ":");
- for (Iterator<Publication> k=list.iterator(); k.hasNext();) {
- Publication doc = k.next();
- String output = "* " + doc.value().getTitle();
- List<Publication> exports = doc.getRelations(ConvertsRelation.class);
- if (exports.size() > 0) {
- output = output + " et export(s)";
- for (Iterator<Publication> m=exports.iterator(); m.hasNext(); ) {
- output = output + " " + m.next().getSourceFile().getName();
- }
- }
- logger.info(output);
- }
- }
- }
- return true;
- }
- catch (Exception e) {
- return false;
- }
- }
-
- private static boolean browse_knowledge () {
-// ------------------------------------------
- try {
- Study study = Database.selectStudy(1);
- Scenario[] branch = study.getScenarii();
- List<KnowledgeElementType> types = KnowledgeElement.selectTypesWhere(ProgressState.APPROVED);
-
- for (int i=0; i<branch.length; i++) {
- Scenario scene = branch[i];
- List<KnowledgeElement> kelms = scene.getAllKnowledgeElements();
- Iterator<KnowledgeElement> more = kelms.iterator();
- KnowledgeElement next = null;
- if (more.hasNext()) next = more.next();
-
- for (Iterator<KnowledgeElementType> j=types.iterator(); j.hasNext();) {
- KnowledgeElementType type = j.next();
- logger.info(type.getName() + ":");
- while (next != null && next.getType().equals(type)) {
- logger.info("* " + next.getTitle() + ": " + next.getValue());
- }
- }
- }
- return true;
- }
- catch (Exception e) {
- return false;
- }
- }
-
- private static boolean read_wordxml_properties () {
-// -------------------------------------------------
- File template = new File("D:/Atelier/Eclipse/salome/org.splat/src/template.xml");
- File copy = new File("D:/Atelier/Eclipse/salome/org.splat/src/example.xml");
- try {
- if (copy.exists()) copy.delete();
- Do.copy(template, copy);
- Writer credoc = Toolbox.getWriter(copy);
- if (credoc != null) {
-
-// Setting of properties
- credoc.updateProperty("customer", "CEA Cadarache");
- credoc.updateProperty("title", "Spécifications générales");
- credoc.save();
-
-// Displaying properties
- Reader example = Toolbox.getReader(copy);
- Revision.Format convert = new Revision.Format("V%M.%m");
- String value;
- logger.info("Properties of \"" + copy.getName() + "\" document:");
-
- value = example.extractProperty("title");
- logger.info("* Title = " + value);
- value = example.extractProperty("version");
- Revision verdoc = convert.parse(value);
- logger.info("* Version = " + verdoc.toString());
- value = example.extractProperty("customer");
- logger.info("* Customer = " + value);
- value = example.extractText();
- logger.info("* Text = " + value);
- }
- return false;
- }
- catch (Exception e) {
- return false;
- }
- }
-
- private static boolean read_worddoc_properties () {
-// -------------------------------------------------
- File file = new File("D:/Atelier/Eclipse/salome/org.splat/src/example.docx");
- try {
- if (!file.exists()) return false;
-
- Reader example = Toolbox.getReader(file);
- logger.info("Properties of \"" + file.getName() + "\" document:");
- String value;
-
- value = example.extractProperty("customer");
- logger.info("* Customer = " + value);
- value = example.extractProperty("title");
- logger.info("* Title = " + value);
- value = example.extractText();
- logger.info("* Text = " + value);
- return false;
- }
- catch (Exception e) {
- return false;
- }*/
- }
-}
\ No newline at end of file