--- /dev/null
+/*****************************************************************************
+ * Copyright Igor Barma, Eric Brun, Alexandre Desoubeaux, Christian Martel,
+ * (2 décembre 2008)
+ *
+ * Ce logiciel est un programme informatique servant à l'évaluation des
+ * compétences.
+ *
+ * Ce logiciel est régi par la licence CeCILL soumise au droit français et
+ * respectant les principes de diffusion des logiciels libres. Vous pouvez
+ * utiliser, modifier et/ou redistribuer ce programme sous les conditions
+ * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
+ * sur le site "http://www.cecill.info".
+ *
+ * En contrepartie de l'accessibilité au code source et des droits de copie,
+ * de modification et de redistribution accordés par cette licence, il n'est
+ * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
+ * seule une responsabilité restreinte pèse sur l'auteur du programme, le
+ * titulaire des droits patrimoniaux et les concédants successifs.
+ *
+ * A cet égard l'attention de l'utilisateur est attirée sur les risques
+ * associés au chargement, à l'utilisation, à la modification et/ou au
+ * développement et à la reproduction du logiciel par l'utilisateur étant
+ * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
+ * manipuler et qui le réserve donc à des développeurs et des professionnels
+ * avertis possédant des connaissances informatiques approfondies. Les
+ * utilisateurs sont donc invités à charger et tester l'adéquation du
+ * logiciel à leurs besoins dans des conditions permettant d'assurer la
+ * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
+ * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
+ *
+ * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
+ * pris connaissance de la licence CeCILL, et que vous en avez accepté les
+ * termes.
+ *******************************************************************************/
+package com.pentila.evalcomp;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Collection;
+import java.util.Set;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.context.SecurityContext;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.UserDetails;
+
+import com.pentila.evalcomp.domain.transit.Activity;
+import com.pentila.evalcomp.domain.transit.Process;
+import com.pentila.evalcomp.domain.transit.Transition;
+import com.pentila.evalcomp.service.interfacedef.IInstance;
+import com.pentila.evalcomp.service.interfacedef.IWorkflow;
+
+
+/**
+ * The Class EvalComp.
+ */
+public class EvalComp {
+
+ /** The ctx. */
+ static ApplicationContext ctx = null;
+
+ /**
+ * Gets the instance manager.
+ *
+ * @return the instance manager
+ */
+ public static IInstance getInstanceManager() {
+ // TODO Auto-generated method stub
+
+ IInstance i = (IInstance) ctx.getBean("instanceManager");
+ return i;
+ }
+
+ /**
+ * Gets the workflow api.
+ *
+ * @return the workflow api
+ */
+ public static IWorkflow getWorkflowAPI() {
+ // TODO Auto-generated method stub
+
+ IWorkflow w = (IWorkflow) ctx.getBean("workflowManager");
+ return w;
+ }
+
+ /**
+ * The main method.
+ *
+ * @param args
+ * the arguments
+ *
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ */
+ public static void main(final String[] args) throws IOException {
+ // TODO Auto-generated method stub
+
+
+
+
+
+
+
+
+ System.out.println("Demarrage");
+ ctx = new ClassPathXmlApplicationContext(new String[] {
+ "applicationContext.xml",
+ "applicationContext-hibernate-bone.xml",
+ "applicationContext-dao.xml",
+ "applicationContext-ldap.xml",
+ "applicationContext-repository.xml",
+
+ "applicationContext-manager.xml",
+ });
+
+
+
+ /*System.out.println("STARRTTTTT ");
+
+
+ IPlanBase pl = (IPlanBase)ctx.getBean("planManager");
+ System.out.println("STARRTTTTT 2");
+
+ long start = System.currentTimeMillis();
+
+
+
+ start = System.currentTimeMillis();
+
+ List<User> l2 = pl.getU2();
+
+ System.out.println("SecondTime is : " + (System.currentTimeMillis() - start));
+
+ System.out.println("Len () : " + l2.size());
+
+ start = System.currentTimeMillis();
+
+ List<User> l1 = pl.getU1();
+
+ System.out.println("FirstTime is : " + (System.currentTimeMillis() - start));
+
+ System.out.println("Len () : " + l1.size());*/
+ /*final Engine e = (Engine) ctx.getBean("engine");
+
+ IEntityBase EM = (IEntityBase) ctx.getBean("entityManager");
+ //e.testProcesses();
+
+ final IInstanceBase instanceManager = (IInstanceBase) ctx.getBean("instanceManager");
+
+ e.testProcesses();*/
+
+
+
+ /*for (int i = 0; i< 1000; i++){
+ MyThread m = new MyThread(e, "JEAN-MICHEL.JULLIEN");
+ Thread th = new Thread(m);
+
+ th.start();
+
+ MyThread m2 = new MyThread(e, "p1000611");
+ Thread th2 = new Thread(m2);
+
+ th2.start();
+ }
+
+ */
+
+ /* List<User> lu = EM.getUsers();
+
+ System.out.println("Users nb : " + lu.size());
+
+
+ for (User u : lu){
+ MyThread m = new MyThread(e, u.getUid());
+ Thread th = new Thread(m);
+
+ th.start();
+ setAuth(u.getUid());
+
+
+ Set<TodoList> t = instanceManager.getTodoLists(u.getUid(), null);
+
+ for (TodoList tl : t){
+ for (Todo todo : tl.getTodos()){
+ String sid = todo.getScenarioInstance().getProcessInstanceId();
+
+ try {
+ Set<ActivityInstance<TaskInstance>> b = e.getAPI().getQueryRuntimeAPI().getTasks(new ProcessInstanceUUID(sid));
+
+ for ( ActivityInstance<TaskInstance> act : b){
+
+ if (act != null && act.getBody() != null && act.getBody().getState().equals(ActivityState.READY) && act.getActivityId().equals("vaepp_evaluer")){
+
+ System.out.println("perform activity with params : " + u.getUid() + " / " + sid + " / " + act.getUUID().toString() + " / TRANSITION_retravailler" );
+
+ instanceManager.performActivity(u.getUid(), sid, act.getUUID().toString(), "TRANSITION_retravailler");
+
+ }else{
+ System.out.println("NOTHING ! (" + act.getActivityId()+ ")");
+ if (act.getBody() != null)
+ System.out.println(act.getBody().getState());
+ }
+
+ }
+
+
+
+
+ } catch (InstanceNotFoundException ee) {
+ // TODO Auto-generated catch block
+ ee.printStackTrace();
+ }
+
+ }
+ }
+ }
+ */
+
+
+ /*ICertificationBase cm = (ICertificationBase)ctx.getBean("certificationManager");
+
+ cm.exportDocuments(new Long(9), new Long(17357));*/
+
+ //Engine e = (Engine) ctx.getBean("engine");
+
+ //e.runProcessTest("", "");
+ //e.displayDB(null);
+ //e.fixState();
+ /*
+ IStatisticBase e = (IStatisticBase) ctx.getBean("statistic");
+
+ Long idED = new Long(32);
+
+ Map<Integer, Integer> m = e.getStatOne(idED);
+
+ String ee = "";
+
+ for (Entry<Integer, Integer> i : m.entrySet()){
+ System.out.println(String.format("%d evalauteurs evalue %d candidats", i.getValue(), i.getKey()));
+ ee = ee + String.format("%d evalauteurs evalue %d candidats\n", i.getValue(), i.getKey());
+ }
+
+ m = e.getStatTwo(idED);
+
+ for (Entry<Integer, Integer> i : m.entrySet()){
+ System.out.println(String.format("%d evalauteurs evalue %d dossiers", i.getValue(), i.getKey()));
+ ee = ee + String.format("%d evalauteurs evalue %d dossiers\n", i.getValue(), i.getKey());
+ }
+
+ m = e.getStatThree(idED);
+
+ for (Entry<Integer, Integer> i : m.entrySet()){
+ System.out.println(String.format("%d evalauteurs evalue %d competences", i.getValue(), i.getKey()));
+ ee = ee + String.format("%d evalauteurs evalue %d competences\n", i.getValue(), i.getKey());
+ }
+
+ m = e.getStatFour(idED);
+
+ for (Entry<Integer, Integer> i : m.entrySet()){
+ System.out.println(String.format("%d candidats ont crée %d dossiers différents", i.getValue(), i.getKey()));
+ ee =ee + String.format("%d candidats ont crée %d dossiers différents\n", i.getValue(), i.getKey());
+ }
+
+
+ String login = "jjullien";
+
+ ByteArrayInputStream fileItem = new ByteArrayInputStream(ee.getBytes());
+
+
+ RessourceFolder ri = new RessourceFolder();
+ ri.setName("Export Campagnes");
+ ri.setPluginKey("JACKRABBIT");
+ ri.setPath("jjullien/");
+
+ Beans.getRessourceBaseBean().addFolder(ri, login);
+
+ Beans.getRessourceBaseBean().addRessourceItem("jjullien", "test.txt", fileItem, "jjullien/Export Campagnes/", "JACKRABBIT");
+
+
+ */
+
+
+ /*Engine e = (Engine) ctx.getBean("engine");
+
+ String actId = "vaepp_creer";
+
+ IInstanceBase sid = (IInstanceBase)ctx.getBean("instanceManagerProxy");
+ IWorkflowBase w = (IWorkflowBase)ctx.getBean("workflowManagerProxy");
+ */
+ //sid.fixErrors();
+
+
+
+
+ /*try {
+ e.printInstanceDebug("Scénario VAEPP-1.6-Scénario_VAEPP-1.6$600");
+ } catch (InstanceNotFoundException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ int count = 0;
+ */
+ /*
+ for (ScenarioInstance si : sid.getAll()){
+
+
+ String id = si.getProcessInstanceId();
+
+
+
+ Set<String> uids = si.getRelatedUsersUid();
+
+ System.out.println(uids);
+
+ try {
+ //e.printInstanceDebug(id);
+ boolean wrong = e.testCoherence(id, uids, actId);
+
+ if (wrong){
+ count++;
+ }
+
+ } catch (Exception e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ //System.out.println("Count of Wrong : " + count);
+
+ }
+ */
+ // IDefinitionBase definitionManager = (IDefinitionBase) ctx
+ // .getBean("definitionManager");
+ // IEntityBase entityManager = (IEntityBase) ctx.getBean("entityManager");
+ // User u = entityManager.getUser("stagiaireM10");
+ //
+ // for (EvaluationDefinition ed : definitionManager
+ // .getEvaluationDefinitions()) {
+ //
+ // for (EntityDefinition edef : ed.getEntityDefinitionsForUser(u)) {
+ //
+ // System.out.println(String.format("%s %s %s", ed.getName(), edef
+ // .getName(), u.getUid()));
+ //
+ // }
+ // }
+
+ /*
+ * IEntityBase entityManager =
+ * (IEntityBase)ctx.getBean("entityManager");
+ *
+ *
+ *
+ *
+ * Group g = entityManager.getGroup("New Groupe");
+ *
+ *
+ *
+ * User u = entityManager.getUser("stagiaireM123");
+ *
+ * g.getUsers().add(u);
+ *
+ * entityManager.editGroup(g);
+ *
+ * Set<User> ss = new HashSet<User>();
+ *
+ * for (User uu : g.getUsers()){ if
+ * (!uu.getUid().equals("stagiaireM123")){ ss.add(uu); } }
+ *
+ * g.setUsers(ss);
+ *
+ *
+ * entityManager.editGroup(g);
+ */
+ /*
+ * IDefinitionBase dm = (IDefinitionBase)
+ * ctx.getBean("definitionManager");
+ *
+ * Set<Long> ss = new HashSet<Long>();
+ *
+ * ss.add(new Long(45));
+ *
+ * dm.deleteESs(ss);
+ */
+ /*
+ * IMethodEvalBase meManager =
+ * (IMethodEvalBase)ctx.getBean("methodEvalManager");
+ *
+ *
+ * for (int y = 2; y < 100 ; y++){ MethodEval mm = meManager.get(new
+ * Long(y)); if (mm != null){ //meManager.deleteMethodEval(mm); } }
+ * MethodEval me = new MethodEval(); me.setName("Hello");
+ * me.setDescription("Desrikds");
+ *
+ *
+ * me = meManager.addMethodEval(me);
+ *
+ * Set<Level> ll = new HashSet<Level>(); for (int i = 0; i<20 ; i++){
+ * Level l = new Level(); l.setName("Niv " + i); l.setValue(i); if (i ==
+ * 10){ l.setThreshold(true); } if (i == 0){ l.setInitial(true); }
+ * l.setMethodEval(me); ll.add(l); System.out.println("Len : " +
+ * ll.size()); }
+ *
+ * me.setLevels(ll);
+ *
+ * me = meManager.updateMethodEval(me);
+ *
+ * for (int j = 0; j <10 ; j++ ){
+ * me.getLevels().remove(me.getLevels().iterator().next()); }
+ *
+ * System.out.println(me.getLevels().size());
+ *
+ * int i = 0; for (Level l : me.getLevels()){ l.setName("Igor " + i);
+ * i++; }
+ *
+ * me = meManager.updateMethodEval(me);
+ *
+ * for (Level l : me.getLevels()){ System.out.println("Level " +
+ * l.getName() + " value = " + l.getValue()); }
+ * me.setName("AAAAAAAAAAAAAAAAAAAAA"); me =
+ * meManager.updateMethodEval(me);
+ */
+
+ // XmlManager xm = new XmlManager();
+
+ /*
+ * IPlan planService = (IPlan)ctx.getBean("planService");
+ * IEvaluationObject eoService = (IEvaluationObject)
+ * ctx.getBean("evaluationObjectService");
+ *
+ * String xml ="";
+ *
+ * File f =new File("/Users/ericbrun/Desktop/Java/C2I2E.xml");
+ *
+ * BufferedReader br = new BufferedReader(new FileReader(f)); String
+ * line; while ((line = br.readLine()) != null){ xml = xml + line; }
+ *
+ *
+ * eoService.importXMLReferentiels(xml);
+ *
+ * Plan p = new Plan();
+ *
+ * p.setCreationDate(new Date()); p.setName("Plan2");
+ * p.setCreatorName("erbru"); p.setOrganisationName("Pentila");
+ *
+ *
+ *
+ * Set<Plan> tmp = planService.getAllPlans();
+ *
+ * if (tmp == null || tmp.isEmpty()){ planService.addPlan(p); }else{ p =
+ * tmp.iterator().next(); }
+ *
+ *
+ *
+ *
+ * PlanRef pr = new PlanRef(); Referentiel r =
+ * eoService.getReferentiel(new Long(1)); pr.setReferentiel(r);
+ *
+ *
+ * pr = planService.addPlanRefToPlan(p.getId(), pr);
+ *
+ * ScenarioDefinitionPlan sdp = new ScenarioDefinitionPlan();
+ * sdp.setName("Scenario2"); sdp.setPackageId("eeee");
+ *
+ * Set<ScenarioDefinitionPlan> ssdp = new
+ * HashSet<ScenarioDefinitionPlan>();
+ *
+ *
+ *
+ * IMethodEvalBase meManager =
+ * (IMethodEvalBase)ctx.getBean("methodEvalManager");
+ *
+ * MethodEval me = meManager.get(new Long(1));
+ *
+ * Set<MethodEval> sme = new HashSet<MethodEval>(); sme.add(me);
+ *
+ * ssdp.add(sdp);
+ *
+ *
+ *
+ * planService.addScenarioDefinitionPlansToPlan(p.getId(), ssdp);
+ * planService.addMethodEvalsToPlan(p.getId(), sme);
+ *
+ * IEntityDAO e = (IEntityDAO)ctx.getBean("entityDAO");
+ *
+ * Entity entity = e.getUser("stagiaireM10");
+ *
+ * Entity entity2 = e.getUser("stagiaireM11"); Entity entity3 =
+ * e.getUser("stagiaireM12"); Set<Entity> entities = new
+ * HashSet<Entity>();
+ *
+ * entities.add(entity);
+ *
+ * String role = "ROLE_GP";
+ * planService.addEntitiesToPlanComponent(p.getId(), entities, role);
+ *
+ * entities.clear(); entities.add(entity2); entities.add(entity3);
+ *
+ * role = "ROLE_EVALUATEUR";
+ *
+ * System.out.println("Plan Ref id : " + pr.getId());
+ *
+ * planService.addEntitiesToPlanComponent(pr.getId(), entities, role);
+ *
+ *
+ * EvaluationObject eo = null; EvaluationObject eo2 = null;
+ * EvaluationObject eo3 = null;
+ *
+ * for (Competence c : r.getAllCompetences()){ if (c.getId().equals(new
+ * Long(6))){ eo = c;
+ *
+ * }else if (c.getId().equals(new Long(7))){ eo2 = c; }else if
+ * (c.getId().equals(new Long(9))){ eo3 = c; } }
+ *
+ *
+ * pr = (PlanRef) planService.setEOToEntity(pr.getId(), entity2, eo,
+ * role); pr = (PlanRef) planService.setEOToEntity(pr.getId(), entity2,
+ * eo2, role); pr = (PlanRef) planService.setEOToEntity(pr.getId(),
+ * entity3, eo3, role);
+ *
+ * pr = (PlanRef)planService.removeEOFromEntity(pr.getId(), entity2,
+ * eo2, role);
+ *
+ * planService.removeEntitiesFromPlanComponent(pr.getId(), entities,
+ * null);
+ *
+ * planService.getPlan(p.getId());
+ *
+ *
+ *
+ *
+ * planService.removeScenarioDefinitionPlans(p.getScenarioDefinitionPlans
+ * ()); planService.removeMethodEvalsFromPlan(p.getMethodEvals());
+ *
+ * planService.removePlanRef(pr.getId());
+ */
+
+ /*
+ * User u = new User(); u.setId(new Long(1)); u.setUid("eric");
+ */
+ // String a = xm.export(u);
+ // User u2 = (User) xm.importer(a);
+ // System.out.println(u2.getUid());
+ // IEntity entityManager = (IEntity)ctx.getBean("entityManager");
+ // IInstanceBase instanceManager = (IInstanceBase)
+ // ctx.getBean("instanceManagerTarget");
+ // Delete User
+ // Set<String> su = new HashSet<String>();
+ // su.add("MONGROUPE");
+ // entityManager.deleteGroups(su);
+ // su.add("stagiaireM10");
+
+ // instanceManager.deleteScenarioInstancesForUsers(su);
+ // entityManager.deleteUsers(su);
+ // entityManager.deleteUsers2(su);
+ /*
+ * su.clear(); su.add("stagiaireM16");
+ *
+ *
+ *
+ * entityManager.deleteUsers(su);
+ *
+ * su.clear(); su.add("stagiaireM17"); entityManager.deleteUsers(su);
+ */
+ /*
+ * Set<String> logins = new HashSet<String>(); for (int i=10; i < 30;
+ * i++){ logins.add("stagiaireM" + "" + i); }
+ *
+ * for (int j = 0; j <3 ; j++){ for (String login : logins){
+ * System.out.println("Login : " + login);
+ * System.out.println(instanceManager.getTodoLists(login).size()); } }
+ */
+ /*
+ * List<Event> le = instanceManager.getEvents("s", 0);
+ *
+ * for (Event e : le) { System.out.println("Notify : " + e.getType());
+ * System.out.println("------------------------------------");
+ * System.out.println("Description : " + e.getDescription());
+ * System.out.println("StartDate : " + e.getStartDate());
+ *
+ * }
+ */
+
+ /*
+ * IEntity em = (IEntity)ctx.getBean("entityManager");
+ *
+ * IEntityDAO ed = (IEntityDAO)ctx.getBean("entityDAO");
+ *
+ * IMessage mm = (IMessage) ctx.getBean("messageManager");
+ *
+ *
+ *
+ * // Create Some Users :
+ *
+ * List<User> lu = new ArrayList<User>();
+ *
+ * for (int i =1; i<100; i++){ User u = new User(); u.setUid("user" +
+ * i); u.setLastname("User" + i); u.setFirstname("User_"+i); u =
+ * ed.saveOrUpdate(u); lu.add(u); }
+ *
+ * Message m = new Message();
+ *
+ *
+ *
+ * m.setAuthor(lu.get(0)); m.setBody("Hello world");
+ * m.setSubject("Subject Hello world");
+ *
+ * Set<Entity> recipients = new HashSet<Entity>();
+ *
+ * for (int j = 1; j < 99 ; j++){ User u = lu.get(j); recipients.add(u);
+ * } m.setRecipients(recipients);
+ *
+ * mm.addMessage(m);
+ *
+ *
+ *
+ * Message m2 = new Message();
+ *
+ *
+ *
+ *
+ * m2.setAuthor(lu.get(0)); m2.setBody("Hello world2");
+ * m2.setSubject("Subejct de 2 de USER1");
+ *
+ * Set<Entity> recipients2 = new HashSet<Entity>();
+ *
+ * for (int j = 1; j < 99 ; j++){ User u = lu.get(j);
+ * recipients2.add(u); } m2.setRecipients(recipients2);
+ *
+ *
+ *
+ * mm.addMessage(m2);
+ *
+ *
+ *
+ * System.out.println(mm.getNbMessages("user2", 1, false));
+ *
+ * Set<Message> smsg = mm.getMessagesList("user2");
+ *
+ * System.out.println("Les Messages de user2 :");
+ *
+ * Message replyUser2 = new Message();
+ * replyUser2.setSubject("OK recu pour user2");
+ * replyUser2.setAuthor(lu.get(1)); for (Message M : smsg){
+ * System.out.println("Message no : " + M.getId());
+ * System.out.println("-->" + M.getSubject()); mm.reply(M.getId(),
+ * replyUser2);
+ *
+ *
+ *
+ * }
+ *
+ * for (User u : lu){
+ *
+ * System.out.println("Nb Message " + u.getUid() +" : " +
+ * mm.getNbMessages(u.getUid(), 1, false)); Set<Message> smsgt =
+ * mm.getMessagesList(u.getUid()); if (smsgt != null){ for (Message mmm
+ * : smsgt){ System.out.println("Dernier Message pour " + u.getUid() +
+ * ": " + mmm.getSubject() + " De : "+ mmm.getAuthor().getUid());
+ *
+ *
+ * System.out.println("Now Read the messages !!");
+ *
+ * mm.readMessage(u.getUid(), mmm.getId());
+ *
+ *
+ *
+ * }} }
+ */
+ /*
+ * IEvaluationDefinitionDAO edDAO = (IEvaluationDefinitionDAO)
+ * ctx.getBean("evaluationDefinitionDAO");
+ *
+ * IInstance im = (IInstance) ctx.getBean("instanceManager");
+ *
+ * Set<TReferentiel> str = im.getUserReferentiels("stagiaireM10");
+ *
+ * for(TReferentiel ttr : str){
+ *
+ *
+ * TReferentiel tr = im.getUserReferentielStates("stagiaireM10",
+ * ttr.getId()); System.out.println("Ref Name : " + tr.getName());
+ * Map<TCompetence, Set<TCompetenceState>> M = tr.getCompetenceInfos();
+ * for (Map.Entry e : M.entrySet()){
+ *
+ * TCompetence tc = (TCompetence)e.getKey(); Set<TCompetenceState> stcs
+ * =(Set<TCompetenceState>) e.getValue();
+ *
+ * System.out.println("-----> Competence : " + tc.getName());
+ * System.out.println("-----> Competence : " + tc.getDescription()); for
+ * (TCompetenceState tcs : stcs){
+ * System.out.println("--------------> Result : " + tcs.isValidable());
+ * System.out.println("--------------> Owner : " + tcs.getOwnerName());
+ *
+ * if(tcs.getEvaluationDefinitionState() !=null){
+ *
+ * System.out.println("--------------> Eval : " +
+ * tcs.getEvaluationDefinitionState().getName()); } }
+ *
+ *
+ * }
+ *
+ *
+ * Map<String, Set<TCompetence>> m = tr.getCompetencesValidability();
+ *
+ * Set<TCompetence> valid = m.get("validable"); Set<TCompetence>
+ * nonvalid = m.get("nonvalidable");
+ *
+ * for(TCompetence tc : valid){
+ * System.out.println("Competence Validable : " + tc.getName());
+ * System.out.println("---------------------> " + tc.getDescription());
+ * } for(TCompetence tc : nonvalid){
+ * System.out.println("Competence NONValidable : " + tc.getName());
+ * System.out.println("---------------------> " + tc.getDescription());
+ * }
+ *
+ *
+ * for (Map.Entry e : tr.getCompetencesByEvaluations().entrySet()){
+ * TEvaluationDefinitionState teds = (TEvaluationDefinitionState)
+ * e.getKey();
+ *
+ * System.out.println("Evaluation " + teds.getName());
+ *
+ *
+ * Set<TCompetence> stc = (Set<TCompetence>) e.getValue(); for
+ * (TCompetence tc: stc){ System.out.println("------------> " +
+ * tc.getName()); } }
+ *
+ *
+ *
+ * }
+ *
+ *
+ *
+ * Map<String, Integer> aa = im.getGroupStat("stagiairesM", new
+ * Long(1));
+ *
+ * for (Map.Entry q : aa.entrySet()){
+ *
+ *
+ * String label = (String)q.getKey(); int nb = (Integer)q.getValue();
+ *
+ * System.out.println("Stat : " + label + " : " + nb);
+ *
+ * }
+ */
+ /*
+ * IEntityDAO eDAO = (IEntityDAO) ctx.getBean("entityDAO");
+ *
+ * IEvaluationObjectDAO eoDAO =
+ * (IEvaluationObjectDAO)ctx.getBean("evaluationObjectDAO");
+ *
+ * User u = new User(); u.setUid("erbru");
+ * u.setEmail("eric@pentila.com"); eDAO.saveOrUpdate(u);
+ *
+ * User u2 = new User(); u2.setUid("vlad"); eDAO.saveOrUpdate(u2);
+ *
+ *
+ *
+ * User ueval = new User(); ueval.setUid("cmart");
+ * eDAO.saveOrUpdate(ueval);
+ *
+ *
+ *
+ * User test = new User(); test.setUid("erbru");
+ *
+ *
+ * Group g = new Group(); g.setUid("PE1");
+ *
+ * Set<User> su = new HashSet<User>();
+ *
+ * su.add(test); g.setUsers(su); g.setType(Entity.INTERN);
+ * eDAO.saveOrUpdate(g);
+ *
+ *
+ *
+ * Group g2 = eDAO.getGroup("PE1"); System.out.println(g2); for (User ee
+ * : g2.getUsers()){ System.out.println(ee.getUid()); }
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * //SynchroManager sm = (SynchroManager) ctx.getBean("synchroManager");
+ * //sm.run();
+ *
+ *
+ *
+ *
+ *
+ *
+ * String xml =
+ * "<?xml version='1.0'?><referentiels><referentiel name='C2i2e'>" +
+ * "<description>Ref c2i</description>" + "<domain name='D1'>" +
+ * "<description>Domain D1</description>" + "<competence name='C1'>"+
+ * "<description>Competence c1</description>" + "</competence>" +
+ * "</domain>" + "<domain name='D2'>" +
+ * "<description>Domain C2</description>" + "<competence name='C2'>" +
+ * "<description>Competence c2</description>" + "</competence>" +
+ * "<competence name='C3'>" + "<description>Domain C3</description>" +
+ * "</competence>" + "<domain name='D21'>" +
+ * "<description>Sous Domaine D21</description>" +
+ * "<competence name='C4'>" + "<description>Competence C4</description>"
+ * + "</competence>" + "<competence name='C5'>" +
+ * "<description>Competence C5</description>" + "</competence>" +
+ * "</domain>" + "</domain>"+ "<domain name='D3'>" +
+ * "<description>Domain D3</description>" + "<competence name='C6'>" +
+ * "<description>Domain C6</description>" + "</competence>" +
+ * "</domain>" + "</referentiel></referentiels>";
+ *
+ *
+ * IEvaluationObject ie= (IEvaluationObject)
+ * ctx.getBean("evaluationObjectManager"); Set<Long> ll =
+ * ie.importXMLReferentiels(xml);
+ *
+ *
+ *
+ * for (Long id : ll){
+ *
+ * //Referentiel r = ie.getReferentiel(id);
+ *
+ * System.out.println(ie.exportXMLReferentiel(id));
+ *
+ * }
+ *
+ *
+ * IWorkflow w = (IWorkflow)ctx.getBean("workflowManager");
+ *
+ *
+ * IEvaluationDefinitionDAO edDAO = (IEvaluationDefinitionDAO)
+ * ctx.getBean("evaluationDefinitionDAO"); IScenarioDefintionDAO sdDAO =
+ * (IScenarioDefintionDAO)ctx.getBean("scenarioDefinitionDAO");
+ * IProcessInstanciationDefinitionDAO pidDAO =
+ * (IProcessInstanciationDefinitionDAO)
+ * ctx.getBean("processInstanciationDefinitionDAO");
+ * IEvaluationSubjectDAO esDAO = (IEvaluationSubjectDAO)
+ * ctx.getBean("evaluationSubjectDAO"); IMethodEvalDAO meDAO =
+ * (IMethodEvalDAO) ctx.getBean("methodEvalDAO"); ILevelDAO lDAO =
+ * (ILevelDAO) ctx.getBean("levelDAO"); IPropertyDAO pDAO =
+ * (IPropertyDAO) ctx.getBean("propertyDAO"); IEntityDefinitionDAO
+ * entityDefDAO = (IEntityDefinitionDAO)
+ * ctx.getBean("entityDefinitionDAO"); IProcessRoleDefinitionDAO prdDAO
+ * = (IProcessRoleDefinitionDAO)
+ * ctx.getBean("processRoleDefinitionDAO"); IEvaluationInstanceDAO EIDAO
+ * = (IEvaluationInstanceDAO) ctx.getBean("evaluationInstanceDAO");
+ * IScenarioInstanceDAO SIDAO = (IScenarioInstanceDAO)
+ * ctx.getBean("scenarioInstanceDAO"); IEvaluationSubjectInstanceDAO
+ * ESIDAO = (IEvaluationSubjectInstanceDAO)
+ * ctx.getBean("evaluationSubjectInstanceDAO"); ICompetenceInstanceDAO
+ * CIDAO = (ICompetenceInstanceDAO)
+ * ctx.getBean("competenceInstanceDAO"); IEventActivityDAO eventDAO =
+ * (IEventActivityDAO)ctx.getBean("eventActivityDAO"); IAcquitmentDAO
+ * acquitDAO = (IAcquitmentDAO) ctx.getBean("acquitmentDAO");
+ *
+ * Set<TransitProcessDefinition> l = w.getProcessDefinitions();
+ *
+ * List<TransitProcessDefinition> ltpd = new
+ * ArrayList<TransitProcessDefinition>(l);
+ *
+ *
+ *
+ * TransitProcessDefinition tpd = ltpd.get(0);
+ *
+ * String defid = tpd.getId(); String defUUID = tpd.getUUID();
+ *
+ * String initRole = w.getProcessDefinitionVariableByUUID(defUUID,
+ * "INIT_ROLE");
+ *
+ * EvaluationDefinition ed = new EvaluationDefinition();
+ * ed.setIndividualInstanciation(true); ed.setName("E1");
+ * ed.setDescription("Evaluation 1"); edDAO.saveOrUpdate(ed);
+ *
+ * ScenarioDefinition sd = new ScenarioDefinition();
+ * sd.setProcessDefinitionId(defid);
+ * sd.setProcessDefinitionUUID(defUUID); sd.setEvaluationDefinition(ed);
+ * sdDAO.saveOrUpdate(sd);
+ *
+ * ProcessInstanciationDefinition pid = new
+ * ProcessInstanciationDefinition(); pidDAO.saveOrUpdate(pid);
+ *
+ *
+ *
+ *
+ *
+ * sd.setPid(pid); sdDAO.saveOrUpdate(sd);
+ *
+ * ProcessRoleDefinition stagiaire = new ProcessRoleDefinition();
+ * stagiaire.setName("Stagiaire"); stagiaire.setPid(pid);
+ * stagiaire.setInitRole(true); prdDAO.saveOrUpdate(stagiaire);
+ *
+ * ProcessRoleDefinition evaluateur = new ProcessRoleDefinition();
+ * evaluateur.setName("Evaluateur"); evaluateur.setPid(pid);
+ * prdDAO.saveOrUpdate(evaluateur);
+ *
+ * EntityDefinition edf1 = new EntityDefinition(); Set<Entity> sss = new
+ * HashSet<Entity>(); sss.add(g2);
+ *
+ *
+ * System.out.println(g2);
+ *
+ * edf1.setEntites(sss); edf1.setEvaluationDefinition(ed);
+ * edf1.setProcessRoleDefinition(stagiaire);
+ * entityDefDAO.saveOrUpdate(edf1);
+ *
+ *
+ * EntityDefinition edf2 = new EntityDefinition(); Set<Entity> sss2 =
+ * new HashSet<Entity>(); sss2.add(ueval); //edf2.setEntites(new
+ * HashSet<Entity>(enseignant.getUsers())); edf2.setEntites(sss2);
+ * edf2.setEvaluationDefinition(ed);
+ * edf2.setProcessRoleDefinition(evaluateur);
+ * entityDefDAO.saveOrUpdate(edf2);
+ *
+ * pid = pidDAO.get(pid.getId());
+ *
+ * System.out.println("Pid de SenarioDef " + sd.getPid());
+ *
+ *
+ * //EvaluationSubject es = new EvaluationSubject();
+ * //es.setEvaluationDefinition(ed); Set<EntityDefinition> sed = new
+ * HashSet<EntityDefinition>(); sed.add(edf2);
+ * //es.setEntityDefinitions(sed);
+ *
+ * //Set<EvaluationObject> seo = new HashSet<EvaluationObject>(); Long
+ * idRef = (Long) (new ArrayList(ll)).get(0);
+ *
+ *
+ * Referentiel r = (Referentiel) eoDAO.get(idRef); //seo.add(r);
+ * //es.setEvaluationObjects(seo); Calendar cal =
+ * Calendar.getInstance();
+ *
+ * for (Domain d : r.getDomains()){ EvaluationSubject es = new
+ * EvaluationSubject(); Set<EvaluationObject> seo = new
+ * HashSet<EvaluationObject>(); seo.add(d);
+ * es.setEvaluationDefinition(ed); es.setEvaluationObjects(seo);
+ * es.setEntityDefinitions(sed); esDAO.saveOrUpdate(es);
+ *
+ * EventActivity eva = new EventActivity();
+ *
+ * eva.setActivityId("prevenir");
+ *
+ * Date endDate = new Date(); cal.setTime(endDate);
+ * cal.add(Calendar.MINUTE, 10); eva.setEndDate(cal.getTime());
+ * eva.setEvaluationSubject(es); eventDAO.saveOrUpdate(eva);
+ *
+ * }
+ *
+ *
+ *
+ *
+ * // MethodEval MethodEval me = new MethodEval();
+ * me.setDescription("Method d'evaluation booleenne");
+ * meDAO.saveOrUpdate(me);
+ *
+ *
+ * // Levels Level l1 = new Level(); l1.setInitial(true);
+ * l1.setName("Level 0"); l1.setValue(0); l1.setMethodEval(me);
+ * lDAO.saveOrUpdate(l1);
+ *
+ *
+ * Level l2 = new Level(); l2.setInitial(false); l2.setName("Level 1");
+ * l2.setValue(1); l2.setMethodEval(me); lDAO.saveOrUpdate(l2);
+ *
+ * meDAO.saveOrUpdate(me);
+ *
+ * me = meDAO.get(me.getId());
+ *
+ * ed.setMethodEval(me); edDAO.saveOrUpdate(ed); ed =
+ * edDAO.get(ed.getId());
+ *
+ *
+ *
+ *
+ * //SynchroManager sm = (SynchroManager)ctx.getBean("synchroManager");
+ * //sm.run();
+ *
+ *
+ *
+ *
+ * // Instanciated !! Level initLevel =
+ * ed.getMethodEval().getInitialLevel();
+ *
+ * //Set<User> forWhoUsers = new HashSet<User>();
+ *
+ * Set<Set<User>> setOfSetOfUser = new HashSet<Set<User>>(); for
+ * (EntityDefinition ED: ed.getInstanciationUnits()){ if
+ * (ed.getIndividualInstanciation()){ for (User U : ED.getUsers()){
+ * Set<User> s = new HashSet<User>(); s.add(U); setOfSetOfUser.add(s); }
+ * }else{ setOfSetOfUser.add(ED.getUsers()); }
+ *
+ * //forWhoUsers.addAll(ED.getUsers());
+ *
+ * } int iiii = 1; for (Set<User> SU : setOfSetOfUser){
+ *
+ * System.out.println("SetofSetOfUser no : " + iiii); iiii = iiii +1;
+ * EvaluationInstance EI = new EvaluationInstance();
+ * EI.setEvaluationDefinition(ed);
+ *
+ * EIDAO.saveOrUpdate(EI);
+ *
+ * for (ScenarioDefinition sdt : ed.getScenarioDefinitions()){
+ * System.out.println("ScenarioDefinition " + sdt.getId()); for
+ * (EvaluationSubject ES : ed.getEvaluationSubjects()){
+ *
+ * System.out.println("EvaluationSubject " + ES.getId());
+ *
+ * EvaluationSubjectInstance ESI = new EvaluationSubjectInstance();
+ * ESI.setEvaluationSubject(ES); ESI.setEvaluationInstance(EI);
+ *
+ * ESIDAO.saveOrUpdate(ESI);
+ *
+ *
+ *
+ * // Build SI
+ *
+ * ScenarioInstance SI = new ScenarioInstance();
+ * SI.setEvaluationInstance(EI); SI.setScenarioDefinition(sdt);
+ * SI.setEvaluationSubjectInstance(ESI);
+ *
+ * ProcessInstanciationDefinition ppp = sdt.getPid(); for
+ * (ProcessRoleDefinition roleDef : ppp.getProcessRoleDefinitions()){
+ * System.out.println("ProcessRoleDefiniton " + roleDef.getId()); for
+ * (EntityDefinition vED : roleDef.getEntityDefinitions()){
+ * System.out.println("EntityDefinition " + vED.getId()); Set<User>
+ * tmpUS = new HashSet<User>(); if
+ * (vED.isAssociateWithInitRoleDefinition()){ tmpUS = SU; }else{ tmpUS =
+ * vED.getUsers(); }
+ *
+ * for (User USU : tmpUS){ String localrole = roleDef.getName() + "_" +
+ * USU.getUid(); System.out.println(localrole);
+ * SI.getLocalroles().add(localrole); }
+ *
+ *
+ * }
+ *
+ * }
+ *
+ * SIDAO.saveOrUpdate(SI);
+ *
+ * // Instanciate Bonita Def !!! Map parameters = new HashMap();
+ *
+ * parameters.put("SIID", SI.getId().toString());
+ *
+ * String wid = w.instanciate("a", sdt.getProcessDefinitionId(),
+ * parameters); System.out.println("Process Bonita Instanciate : " +
+ * wid);
+ *
+ * SI.setProcessInstanceId(wid);
+ *
+ * SIDAO.saveOrUpdate(SI); ///
+ *
+ *
+ * // Build CompetenceInstance for (EvaluationObject EO :
+ * ES.getEvaluationObjects()){ System.out.println("Eval object" +
+ * EO.getId()); for (Competence C : EO.getAllCompetences()){
+ * System.out.println("Competences" + C.getId()); for (User UUU : SU){
+ * System.out.println("User " + UUU.getUid()); CompetenceInstance CI =
+ * new CompetenceInstance(); CI.setEvaluationSubjectInstance(ESI);
+ * CI.setEvaluationInstance(EI); CI.setCompetence(C);
+ * CI.setLevel(initLevel); CI.setOwner(UUU);
+ *
+ * Date d = new Date();
+ *
+ * CI.setLastModified(d); CIDAO.saveOrUpdate(CI); } } }
+ *
+ *
+ * }
+ *
+ *
+ * }
+ *
+ *
+ *
+ * }
+ *
+ *
+ *
+ *
+ *
+ * boolean next = false;
+ *
+ * next= printTodo(); while (next){ prompt(); next = printTodo(); }
+ */
+
+ }
+
+ /**
+ * Prints the todo.
+ *
+ * @return true, if successful
+ */
+ public static boolean printTodo() {
+ String[] uids = { "erbru", "cmart", "worker" };
+
+ boolean left = false;
+
+ for (String uid : uids) {
+ System.out.println("PROCESSES for " + uid);
+
+ Set<Process> sp = getWorkflowAPI().getProcesses(uid);
+
+ for (Process p : sp) {
+ System.out.println("process id : " + p.getId());
+ Set<Activity> SA = p.getActivities();
+
+ if (!SA.isEmpty()) {
+ left = true;
+ }
+
+ for (Activity A : SA) {
+ System.out.println(" " + A.getId() + " : "
+ + A.getDescription());
+ for (Transition t : A.getTransitions()) {
+ System.out.println(" " + t.getId() + " : "
+ + t.getName() + " : " + t.getDescription());
+ }
+ }
+ }
+ }
+ return left;
+ }
+
+ /**
+ * Prompt.
+ */
+ public static void prompt() {
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+
+ String login = "";
+ String puuid = "";
+ String aid = "";
+ String tid = "";
+ try {
+ System.out.println("Login : ");
+ login = br.readLine();
+ System.out.println("Process ID : ");
+ puuid = br.readLine();
+ System.out.println("Activity ID : ");
+ aid = br.readLine();
+ System.out.println("Transition ID : ");
+ tid = br.readLine();
+ System.out.println("value : ");
+ br.readLine();
+ getWorkflowAPI().runProcessActivity(login, puuid, aid, tid);
+
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+
+
+ /**
+ * Sets the auth.
+ *
+ * @param login the new auth
+ */
+ public static void setAuth(final String login){
+
+ System.out.println("setAuth : " + login);
+
+
+ SecurityContext securityContext = SecurityContextHolder.getContext();
+
+
+
+
+
+ Authentication auth = new Authentication(){
+
+ public String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Collection<GrantedAuthority> getAuthorities() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getCredentials() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getDetails() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getPrincipal() {
+ UserDetails p = new UserDetails(){
+
+ public Collection<GrantedAuthority> getAuthorities() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getPassword() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getUsername() {
+ return login;
+ }
+
+ public boolean isAccountNonExpired() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isAccountNonLocked() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isCredentialsNonExpired() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isEnabled() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+
+ };
+
+ return p;
+ }
+
+ public boolean isAuthenticated() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setAuthenticated(boolean arg0)
+ throws IllegalArgumentException {
+ // TODO Auto-generated method stub
+
+ }
+
+ };
+
+ securityContext.setAuthentication(auth);
+ }
+
+ /**
+ * Gets the auth.
+ *
+ * @return the auth
+ */
+ public static String getAuth(){
+ try{
+ SecurityContext securityContext = SecurityContextHolder.getContext();
+
+ org.springframework.security.core.userdetails.UserDetails su = (UserDetails) securityContext
+ .getAuthentication().getPrincipal();
+
+ return su.getUsername();
+ }catch (Exception e){
+
+ }
+ return "";
+ }
+}