[Castore-commits] JDOUserEventFactory.java 1.13 1.14
JDOUserMaintenance.java 1.10 1.11
Stéphane Bouchet
sbouchet at adullact1.hosting.cri74.org
Ven 19 Mai 14:09:22 CEST 2006
Update of /cvsroot/castore/castore-core/src/java/fr/emn/castor/users/jdo
In directory adullact1:/tmp/cvs-serv3277/src/java/fr/emn/castor/users/jdo
Modified Files:
JDOUserEventFactory.java JDOUserMaintenance.java
Log Message:
correction bug gestion du profil des validatuers potentiel d'un document.
Index: JDOUserEventFactory.java
===================================================================
RCS file: /cvsroot/castore/castore-core/src/java/fr/emn/castor/users/jdo/JDOUserEventFactory.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** JDOUserEventFactory.java 16 May 2006 15:26:14 -0000 1.13
--- JDOUserEventFactory.java 19 May 2006 12:09:20 -0000 1.14
***************
*** 61,64 ****
--- 61,65 ----
import fr.emn.castor.common.jdo.JDOQuery;
import fr.emn.castor.documents.DocumentsConstants.StateEnum;
+ import fr.emn.castor.documents.metier.docGenerique.ADocument;
import fr.emn.castor.groupes.Facade;
import fr.emn.castor.groupes.GroupesConstants;
***************
*** 223,229 ****
//test 1 : sur l'utilisateur
! if (docFac
! .finishedValidationForGroupOrUser(validator, idDoc)==
! VraiFauxEnum.VRAI) {
if (log.isDebugEnabled()) {
log.debug("Validation terminee pour : " + validator
--- 224,228 ----
//test 1 : sur l'utilisateur
! if (docFac.finishedValidationForGroupOrUser(validator, idDoc) == VraiFauxEnum.VRAI) {
if (log.isDebugEnabled()) {
log.debug("Validation terminee pour : " + validator
***************
*** 239,245 ****
// test 2 : sur le groupe des documentalistes
if (docFac.finishedValidationForGroupOrUser(
! Constants.SESSION_DOCUMENTALIST_KEY, idDoc)==
! VraiFauxEnum.VRAI) {
!
if (log.isDebugEnabled()) {
log.debug("Validation terminee pour : "
--- 238,242 ----
// test 2 : sur le groupe des documentalistes
if (docFac.finishedValidationForGroupOrUser(
! Constants.SESSION_DOCUMENTALIST_KEY, idDoc) == VraiFauxEnum.VRAI) {
if (log.isDebugEnabled()) {
log.debug("Validation terminee pour : "
***************
*** 256,261 ****
// test 3 : sur le groupe des superviseurs
if (docFac.finishedValidationForGroupOrUser(
! Constants.SESSION_SUPERVISOR_KEY, idDoc)==
! VraiFauxEnum.VRAI) {
if (log.isDebugEnabled()) {
log.debug("Validation terminee pour : "
--- 253,257 ----
// test 3 : sur le groupe des superviseurs
if (docFac.finishedValidationForGroupOrUser(
! Constants.SESSION_SUPERVISOR_KEY, idDoc) == VraiFauxEnum.VRAI) {
if (log.isDebugEnabled()) {
log.debug("Validation terminee pour : "
***************
*** 277,281 ****
//pour cela, on recupere l'etape suivante
String validateur = docFac.getValidatorsListForDocument(idDoc);
! this.addNewDocAValider(validateur, idDoc);
}
--- 273,279 ----
//pour cela, on recupere l'etape suivante
String validateur = docFac.getValidatorsListForDocument(idDoc);
! if (validateur != null) {
! this.addNewDocAValider(validateur, idDoc);
! }
}
***************
*** 953,966 ****
//suppression de la liste des valideurs potentiels
PersistenceManager pm = JDOFactory.getPersistenceManager();
! this.jdoQuery.setPersistenceManager(pm);
! Iterator validators = this.getValidatorListWithThisDoc(idDoc);
! ValidatorGroupProfil docGroupProfil = this.getDocumentalistsProfil();
! ValidatorGroupProfil supGroupProfil = this.getSupervisorsProfil();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
! while (validators.hasNext()) {
! Validator temp = (Validator) validators.next();
! temp.removeDocAValider(idDoc);
}
//suppression de la liste des groupes de valideurs
--- 951,964 ----
//suppression de la liste des valideurs potentiels
PersistenceManager pm = JDOFactory.getPersistenceManager();
! List<Validator> validators = this.getValidatorListWithThisDoc(
! pm, idDoc);
! ValidatorGroupProfil docGroupProfil = this
! .getDocumentalistsProfil(pm);
! ValidatorGroupProfil supGroupProfil = this.getSupervisorsProfil(pm);
Transaction tx = pm.currentTransaction();
try {
tx.begin();
! for (Validator validator : validators) {
! validator.removeDocAValider(idDoc);
}
//suppression de la liste des groupes de valideurs
***************
*** 1007,1012 ****
public void removeDocForDocumentalist(final String idDoc) {
PersistenceManager pm = JDOFactory.getPersistenceManager();
! this.jdoQuery.setPersistenceManager(pm);
! ValidatorGroupProfil group = this.getDocumentalistsProfil();
Transaction tx = pm.currentTransaction();
try {
--- 1005,1009 ----
public void removeDocForDocumentalist(final String idDoc) {
PersistenceManager pm = JDOFactory.getPersistenceManager();
! ValidatorGroupProfil group = this.getDocumentalistsProfil(pm);
Transaction tx = pm.currentTransaction();
try {
***************
*** 1031,1036 ****
public void removeDocForSupervisor(final String idDoc) {
PersistenceManager pm = JDOFactory.getPersistenceManager();
! this.jdoQuery.setPersistenceManager(pm);
! ValidatorGroupProfil group = this.getSupervisorsProfil();
Transaction tx = pm.currentTransaction();
try {
--- 1028,1032 ----
public void removeDocForSupervisor(final String idDoc) {
PersistenceManager pm = JDOFactory.getPersistenceManager();
! ValidatorGroupProfil group = this.getSupervisorsProfil(pm);
Transaction tx = pm.currentTransaction();
try {
***************
*** 1054,1065 ****
* @return
*/
! private Iterator getValidatorListWithThisDoc(final String idDoc) {
String filter = "docsAValider.contains(\"" + idDoc + "\")";
! Collection retour = (Collection) this.jdoQuery.query(
! filter, false, false, Validator.class);
! if (retour == null) {
! retour = new ArrayList();
}
! return retour.iterator();
}
--- 1050,1063 ----
* @return
*/
! private List<Validator> getValidatorListWithThisDoc(
! final PersistenceManager pm, final String idDoc) {
String filter = "docsAValider.contains(\"" + idDoc + "\")";
! Query query = pm.newQuery(Validator.class, filter);
! List queryRes = (List) query.execute();
! ArrayList<Validator> result = new ArrayList<Validator>();
! for (int i = 0; i < queryRes.size(); i++) {
! result.add((Validator) queryRes.get(i));
}
! return result;
}
***************
*** 1089,1096 ****
ValidatorGroupProfil groupProfil = null;
if (validator.equals(Constants.SESSION_DOCUMENTALIST_KEY)) {
! groupProfil = getDocumentalistsProfil();
} else if (validator
.equals(Constants.SESSION_SUPERVISOR_KEY)) {
! groupProfil = getSupervisorsProfil();
} else {
if (log.isFatalEnabled()) {
--- 1087,1094 ----
ValidatorGroupProfil groupProfil = null;
if (validator.equals(Constants.SESSION_DOCUMENTALIST_KEY)) {
! groupProfil = getDocumentalistsProfil(pm);
} else if (validator
.equals(Constants.SESSION_SUPERVISOR_KEY)) {
! groupProfil = getSupervisorsProfil(pm);
} else {
if (log.isFatalEnabled()) {
***************
*** 1144,1149 ****
.getInstance();
try {
! if (userFac.isValidateur(validator)==
! VraiFauxEnum.VRAI) {
Map userMap = fr.emn.castor.users.Facade
.getInstance().getInfosFromUser(validator);
--- 1142,1146 ----
.getInstance();
try {
! if (userFac.isValidateur(validator) == VraiFauxEnum.VRAI) {
Map userMap = fr.emn.castor.users.Facade
.getInstance().getInfosFromUser(validator);
***************
*** 1221,1250 ****
* @return
*/
! private ValidatorGroupProfil getSupervisorsProfil() {
! PersistenceManager pm = JDOFactory.getPersistenceManager();
! this.jdoQuery.setPersistenceManager(pm);
! ValidatorGroupProfil result = (ValidatorGroupProfil) this.jdoQuery
! .query("", true, true, SupervisorGroupProfil.class);
! if (result == null) {
! ValidatorGroupProfil groupProfil = new SupervisorGroupProfil();
! pm = JDOFactory.getPersistenceManager();
! Transaction tx = pm.currentTransaction();
! try {
tx.begin();
// make the object user persistent in the database
pm.makePersistent(groupProfil);
tx.commit();
! result = (ValidatorGroupProfil) pm.detachCopy(groupProfil);
! } catch (Exception e) {
! if (log.isErrorEnabled()) {
! log.error(e.getMessage(), e);
! }
! } finally {
! if (tx.isActive()) {
! tx.rollback();
! }
}
}
- return result;
}
--- 1218,1251 ----
* @return
*/
! private ValidatorGroupProfil getSupervisorsProfil(
! final PersistenceManager pm) {
! Transaction tx = pm.currentTransaction();
! try {
! tx.begin();
! Query query = pm.newQuery(SupervisorGroupProfil.class);
! query.setUnique(true);
! ValidatorGroupProfil result = (ValidatorGroupProfil) query
! .execute();
! query.closeAll();
! tx.commit();
! if (result == null) {
! ValidatorGroupProfil groupProfil = new SupervisorGroupProfil();
tx.begin();
// make the object user persistent in the database
pm.makePersistent(groupProfil);
tx.commit();
! result = groupProfil;
! }
! return result;
! } catch (Exception e) {
! if (log.isErrorEnabled()) {
! log.error(e.getMessage(), e);
! }
! return null;
! } finally {
! if (tx.isActive()) {
! tx.rollback();
}
}
}
***************
*** 1253,1284 ****
* @return
*/
! private ValidatorGroupProfil getDocumentalistsProfil() {
!
! PersistenceManager pm = JDOFactory.getPersistenceManager();
! this.jdoQuery.setPersistenceManager(pm);
! ValidatorGroupProfil result = (ValidatorGroupProfil) this.jdoQuery
! .query("", true, true, DocumentalistGroupProfil.class);
! if (result == null) {
! DocumentalistGroupProfil groupProfil = new DocumentalistGroupProfil();
! pm = JDOFactory.getPersistenceManager();
! Transaction tx = pm.currentTransaction();
! try {
tx.begin();
// make the object user persistent in the database
pm.makePersistent(groupProfil);
tx.commit();
! result = (ValidatorGroupProfil) pm.detachCopy(groupProfil);
! } catch (Exception e) {
! if (log.isErrorEnabled()) {
! log.error(e.getMessage(), e);
! }
! } finally {
! if (tx.isActive()) {
! tx.rollback();
! }
! pm.close();
}
}
- return result;
}
--- 1254,1287 ----
* @return
*/
! private ValidatorGroupProfil getDocumentalistsProfil(
! final PersistenceManager pm) {
! Transaction tx = pm.currentTransaction();
! try {
! tx.begin();
! Query query = pm.newQuery(DocumentalistGroupProfil.class);
! query.setUnique(true);
! ValidatorGroupProfil result = (ValidatorGroupProfil) query
! .execute();
! query.closeAll();
! tx.commit();
! if (result == null) {
! ValidatorGroupProfil groupProfil = new DocumentalistGroupProfil();
tx.begin();
// make the object user persistent in the database
pm.makePersistent(groupProfil);
tx.commit();
! result = groupProfil;
! }
! return result;
! } catch (Exception e) {
! if (log.isErrorEnabled()) {
! log.error(e.getMessage(), e);
! }
! return null;
! } finally {
! if (tx.isActive()) {
! tx.rollback();
}
}
}
Index: JDOUserMaintenance.java
===================================================================
RCS file: /cvsroot/castore/castore-core/src/java/fr/emn/castor/users/jdo/JDOUserMaintenance.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** JDOUserMaintenance.java 18 May 2006 15:42:40 -0000 1.10
--- JDOUserMaintenance.java 19 May 2006 12:09:20 -0000 1.11
***************
*** 689,693 ****
//map de retour
Map<String, Object> retour = new HashMap<String, Object>();
-
//recuperation de l'utilisateur ...
AbstractUser user = this.getUser(userId);
--- 689,692 ----
***************
*** 699,706 ****
return new HashMap<String, Object>();
}
-
//... et de son profil
UserProfil userProfil = user.getUserProfil();
-
//recuperation et sauvegarde dans la map des documents prives
List<String> docPrives = userProfil.getDocsPrives();
--- 698,703 ----
***************
*** 709,713 ****
.getDocsPrives().size());
retour.put(UsersConstants.INFO_PROFIL_NB_DOCS_PRIVES, nbDocsPrives);
-
//recuperation et sauvegarde dans la map des documents partages
// acceptes
--- 706,709 ----
Plus d'informations sur la liste de diffusion Castore-commits