001: /**
002: *
003: * Bonita
004: * Copyright (C) 1999 Bull S.A.
005: * Bull 68 route de versailles 78434 Louveciennes Cedex France
006: * Further information: bonita@objectweb.org
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Lesser General Public
010: * License as published by the Free Software Foundation; either
011: * version 2.1 of the License, or any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public
019: * License along with this library; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
021: * USA
022: *
023: *
024: --------------------------------------------------------------------------
025: * $Id: UpdateEnumDyn2.java,v 1.1 2006/08/07 10:01:26 mvaldes Exp $
026: *
027: --------------------------------------------------------------------------
028: */package hero.hook;
029:
030: import java.util.ArrayList;
031: import java.util.Collection;
032: import java.util.Iterator;
033: import java.util.TreeSet;
034:
035: import hero.util.HeroHookException;
036: import hero.interfaces.BnNodeLocal;
037: import hero.interfaces.BnNodePropertyValue;
038: import hero.interfaces.BnProjectLocal;
039: import hero.interfaces.Constants;
040: import hero.interfaces.ProjectSession;
041: import hero.interfaces.ProjectSessionHome;
042: import hero.interfaces.ProjectSessionUtil;
043:
044: public class UpdateEnumDyn2 implements hero.hook.NodeHookI {
045:
046: public String getMetadata() {
047: return Constants.Nd.ONREADY;
048: }
049:
050: public void create(Object b, BnNodeLocal n)
051: throws HeroHookException {
052: }
053:
054: public void beforeStart(Object b, BnNodeLocal n)
055: throws HeroHookException {
056: }
057:
058: public void beforeTerminate(Object b, BnNodeLocal n)
059: throws HeroHookException {
060: try {
061:
062: BnProjectLocal project = n.getBnProject();
063: String prjName = project.getName();
064:
065: ProjectSessionHome prjhome = (ProjectSessionHome) ProjectSessionUtil
066: .getHome();
067: ProjectSession prjSession = prjhome.create();
068: prjSession.initProject(prjName);
069:
070: String nodeName = n.getName();
071:
072: TreeSet setSCRoles = new TreeSet();
073: setSCRoles.add("new1");
074: setSCRoles.add("new2");
075:
076: ArrayList arDefault = new ArrayList();
077: arDefault.add("new1");
078:
079: prjSession.updateNodePropertyPossibleValues(nodeName,
080: "enumdyn", setSCRoles, arDefault);
081:
082: prjSession.setNodeProperty(nodeName, "testProp", "no");
083:
084: } catch (Exception e) {
085: throw new HeroHookException(e.getMessage());
086: }
087: }
088:
089: public void afterTerminate(Object b, BnNodeLocal n)
090: throws HeroHookException {
091: }
092:
093: public void onCancel(Object b, BnNodeLocal n)
094: throws HeroHookException {
095: }
096:
097: public void anticipate(Object b, BnNodeLocal n)
098: throws HeroHookException {
099: }
100:
101: public void onDeadline(Object b, BnNodeLocal n)
102: throws HeroHookException {
103: }
104:
105: public void afterStart(Object b, BnNodeLocal n)
106: throws HeroHookException {
107: }
108:
109: public void onReady(Object b, BnNodeLocal n)
110: throws HeroHookException {
111: }
112:
113: }
|