cancel
Showing results for 
Search instead for 
Did you mean: 

[Résolu]Trouver un Node, Action(Rule) avec son id Class Java

leyer
Champ in-the-making
Champ in-the-making
Bonjour tout le monde,
Je rencontre un petit problème lors de la creation de mon webscript Java.
Il prend en parametre l'id d'un node ref.
Je souhaite recuperer mon node ref du genre
NodeRef test = getnoderef(id)
Mais je ne trouve pas dans alfresco une classe me permettant de retourner un node ref en lui donnant une string (id)
Y'a t'il un moyen de recuperer mes noderef en java grace à c'est ID ?
11 REPLIES 11

bertrandf
Champ on-the-rise
Champ on-the-rise
NodeRef(String nodeRef)
NodeRef(StoreRef storeRef, String id)
NodeRef(String protocol, String identifier,String id)

Exemple :
NodeRef node = new NodeRef(nodeRef); //Si vous avez le nodeRef
NodeRef node = new NodeRef(new StoreRef("workspace", "SpacesStore"), id); //Si vous avez que l'id et que le Store et le workspace://SpacesStore
NodeRef node = new NodeRef("workspace", "SpacesStore", id);
   

http://dev.alfresco.com/resource/docs/java/repository/org/alfresco/service/cmr/repository/NodeRef.ht...

leyer
Champ in-the-making
Champ in-the-making
Bonjour Bertrand merci beaucoup de cette reponse rapide Smiley Happy
j'essai cela et vous donne des nouvelles Smiley Wink

leyer
Champ in-the-making
Champ in-the-making
Ca à l'air de fonctionner.
Mon id est un id d'une rule es possible de retrouver les parametre de cette regle grace à l'actionService ?


NodeRef actionedUponNodeRef = new NodeRef(new StoreRef("workspace", "SpacesStore"), this.ActionID);
            Action ruleAction = actionService.getAction(actionedUponNodeRef,this.RuleID);

Il doit me manquer de quoi ^^ :roll:

leyer
Champ in-the-making
Champ in-the-making
Bon j'ai cherché un peu je vous explique la situation j'ai un noderef qui est enfait un document du type .doc etc …
Apres j'ai l'id d'une régle de contenu genre mail notification.
J'aimerai recuperer une une action genre :


NodeRef docNode = new NodeRef(new StoreRef("workspace", "SpacesStore"), temp[1]);
Action ruleAction = this.actionService.getActions(docNode,this.RuleID);

Mais sa me retourne null a chaque fois …

En gros j'aimerai récuperer l'action dont j'ai l'id … et de type action …

leyer
Champ in-the-making
Champ in-the-making
une idée ?

leyer
Champ in-the-making
Champ in-the-making
en gros je voudrais pouvoir repurer les propriété d'une action…

yannb
Champ in-the-making
Champ in-the-making
Salut,
Etes vous sur que le docNode n'est pas null ?

Que donnerait :
List<Action> actions = this.actionService.getActions(this.nodeRef);

Que contient actions ?

leyer
Champ in-the-making
Champ in-the-making
sa retourne un null…. pourtant le noderef que j'utilise je le voit bien dans le noderef browser …

Actions contient [] …
Noderef du document est bien exact …
MAis je tiens a préciser que c'Est bien un noeud de document et non pas un dossier le dossier ou la règle a été mise est bcp plus haut mais la regle s'applique a tout les enfant …
Donc dans la theorie je suis sensé pouvoir recuperer cette action ….
Surtout que j'ai son Id ….je ne comprend pas pourquoi on peut recuperer le nodered d'une action mais mais une Action grace a ce noderef ….

leyer
Champ in-the-making
Champ in-the-making
J'ai finalement trouvé la solution avec beaucoup de persévérance  :mrgreen:


NodeRef rule = new NodeRef(new StoreRef("workspace", "SpacesStore"), temp[2] );
   List<ChildAssociationRef> children = nodeService.getChildAssocs(rule);
   for (ChildAssociationRef childAssoc : children) {
      NodeRef childNodeRef = childAssoc.getChildRef();
      String tempory_name = (String)this.nodeService.getProperty(childNodeRef, QName.createQName("http://www.alfresco.org/model/action/1.0", "parameterName"));
      if(tempory_name != null){
         if(tempory_name.equals("template")){
            this.templateRef_x = childNodeRef;
         }
         if(tempory_name.equals("text")){
            this.text_x = (String)this.nodeService.getProperty(childNodeRef, QName.createQName("http://www.alfresco.org/model/action/1.0", "parameterValue"));
         }
         if(tempory_name.equals("to")){
            this.to_x=(String)this.nodeService.getProperty(childNodeRef, QName.createQName("http://www.alfresco.org/model/action/1.0", "parameterValue"));
         }
         if(tempory_name.equals("to_many")){
            this.to_many_x = this.nodeService.getProperty(childNodeRef, QName.createQName("http://www.alfresco.org/model/action/1.0", "parameterValue"));
         }
         if(tempory_name.equals("from")){
            this.from_x = (String)this.nodeService.getProperty(childNodeRef, QName.createQName("http://www.alfresco.org/model/action/1.0", "parameterValue"));
         }
         if(tempory_name.equals("subject")){
            this.Subject_x = (String)this.nodeService.getProperty(childNodeRef, QName.createQName("http://www.alfresco.org/model/action/1.0", "parameterValue"));
         }
      }
   }