--- /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.domain.transit;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import com.pentila.evalcomp.domain.EObject;
+import com.pentila.evalcomp.domain.User;
+import com.pentila.evalcomp.domain.definition.ProcessRoleDefinition;
+import com.pentila.evalcomp.domain.plan.PlanRef;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class TReferentiel.
+ */
+public class TReferentiel extends EObject {
+
+ /** The competence infos. */
+ Map<TCompetence, Set<TCompetenceState>> competenceInfos = new HashMap<TCompetence, Set<TCompetenceState>>();
+
+ /** The description. */
+ String description;
+
+ /** The forme. */
+ boolean forme = false;
+
+ /** The id. */
+ Long id;
+
+ /** The name. */
+ String name;
+
+ /** The related users. */
+ Set<User> relatedUsers = new HashSet<User>();
+
+ /** The process role definitions. */
+ Set<ProcessRoleDefinition> processRoleDefinitions;
+
+ Set<PlanRef> planRefs;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+
+ try {
+ TReferentiel o = (TReferentiel) obj;
+ return this.getId().equals(o.getId());
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ /**
+ * Gets the competence infos.
+ *
+ * @return the competence infos
+ */
+ public Map<TCompetence, Set<TCompetenceState>> getCompetenceInfos() {
+ return competenceInfos;
+ }
+
+ /**
+ * Gets the competences by domains.
+ *
+ * @return the competences by domains
+ */
+ public Map<TDomain, Set<TCompetence>> getCompetencesByDomains() {
+
+ Map<TDomain, Set<TCompetence>> m = new HashMap<TDomain, Set<TCompetence>>();
+ Map<String, Set<TCompetence>> cv = this.getCompetencesValidability();
+
+ Set<TCompetence> all = cv.get("validable");
+ all.addAll(cv.get("nonvalidable"));
+
+ for (TCompetence tc : all) {
+ TDomain td = tc.getDomain();
+
+ if (!m.containsKey(td)) {
+ m.put(td, new HashSet<TCompetence>());
+ }
+
+ m.get(td).add(tc);
+
+ }
+
+ return m;
+ }
+
+ /**
+ * Gets the competences by evaluations.
+ *
+ * @return the competences by evaluations
+ */
+ public Map<TEvaluationDefinitionState, Set<TCompetence>> getCompetencesByEvaluations() {
+ Map<TEvaluationDefinitionState, Set<TCompetence>> TES = new HashMap<TEvaluationDefinitionState, Set<TCompetence>>();
+
+ TEvaluationDefinitionState LostEval = new TEvaluationDefinitionState();
+ LostEval.setId(new Long(0));
+
+ Set<TCompetence> lostset = new HashSet<TCompetence>();
+
+ TES.put(LostEval, lostset);
+
+ for (Entry e : this.getCompetenceInfos().entrySet()) {
+ TCompetence tc = (TCompetence) e.getKey();
+
+ Set<TCompetenceState> stcs = (Set<TCompetenceState>) e.getValue();
+
+ if (stcs == null || stcs.isEmpty()) {
+ TES.get(LostEval).add(tc);
+ } else {
+ for (TCompetenceState tcs : stcs) {
+ TEvaluationDefinitionState TEDS = tcs
+ .getEvaluationDefinitionState();
+
+ if (TEDS == null) {
+
+ // Remove this : it obso ...
+
+ TEDS = LostEval;
+ } else {
+ if (!TES.containsKey(TEDS)) {
+ TES.put(TEDS, new HashSet<TCompetence>());
+ }
+ }
+
+ TES.get(TEDS).add(tc);
+
+ }
+ }
+
+ }
+ return TES;
+ }
+
+ /**
+ * Gets the competences validability.
+ *
+ * @return the competences validability
+ */
+ public Map<String, Set<TCompetence>> getCompetencesValidability() {
+ Map<String, Set<TCompetence>> m = new HashMap<String, Set<TCompetence>>();
+ Set<TCompetence> stc = new HashSet<TCompetence>();
+ Set<TCompetence> stcw = new HashSet<TCompetence>();
+ for (Entry e : this.getCompetenceInfos().entrySet()) {
+ TCompetence tc = (TCompetence) e.getKey();
+ Set<TCompetenceState> stcs = (Set<TCompetenceState>) e.getValue();
+ boolean validable = false;
+ for (TCompetenceState tcs : stcs) {
+ if (tcs.isValidable()) {
+ validable = true;
+ break;
+ }
+ }
+ if (validable) {
+ stc.add(tc);
+ } else {
+ stcw.add(tc);
+ }
+ }
+
+ m.put("validable", stc);
+ m.put("nonvalidable", stcw);
+
+ return m;
+ }
+
+ /**
+ * Gets the description.
+ *
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Gets the id.
+ *
+ * @return the id
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the related users.
+ *
+ * @return the related users
+ */
+ public Set<User> getRelatedUsers() {
+ return this.relatedUsers;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return this.getId().intValue();
+ }
+
+ /**
+ * Checks if is forme.
+ *
+ * @return true, if is forme
+ */
+ public boolean isForme() {
+ return forme;
+ }
+
+ /**
+ * Sets the competence infos.
+ *
+ * @param competenceInfos
+ * the competence infos
+ */
+ public void setCompetenceInfos(
+ Map<TCompetence, Set<TCompetenceState>> competenceInfos) {
+ this.competenceInfos = competenceInfos;
+ }
+
+ /**
+ * Sets the description.
+ *
+ * @param description
+ * the new description
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Sets the forme.
+ *
+ * @param forme
+ * the new forme
+ */
+ public void setForme(boolean forme) {
+ this.forme = forme;
+ }
+
+ /**
+ * Sets the id.
+ *
+ * @param id
+ * the new id
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ /**
+ * Sets the name.
+ *
+ * @param name
+ * the new name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Sets the related users.
+ *
+ * @param su
+ * the new related users
+ */
+ public void setRelatedUsers(Set<User> su) {
+ this.relatedUsers = su;
+
+ }
+
+ /**
+ * Sets the process role definitions.
+ *
+ * @param sprd the new process role definitions
+ */
+ public void setProcessRoleDefinitions(Set<ProcessRoleDefinition> sprd) {
+ // TODO Auto-generated method stub
+ this.processRoleDefinitions = sprd;
+ }
+
+ /**
+ * Gets the process role definitions.
+ *
+ * @return the process role definitions
+ */
+ public Set<ProcessRoleDefinition> getProcessRoleDefinitions() {
+ return processRoleDefinitions;
+ }
+
+ public Set<PlanRef> getPlanRefs() {
+ return planRefs;
+ }
+
+ public void setPlanRefs(Set<PlanRef> planRefs) {
+ this.planRefs = planRefs;
+ }
+
+}
\ No newline at end of file