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: UpdateEnumDyn3.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 UpdateEnumDyn3 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: }
061:
062: public void afterTerminate(Object b, BnNodeLocal n)
063: throws HeroHookException {
064: }
065:
066: public void onCancel(Object b, BnNodeLocal n)
067: throws HeroHookException {
068: }
069:
070: public void anticipate(Object b, BnNodeLocal n)
071: throws HeroHookException {
072: }
073:
074: public void onDeadline(Object b, BnNodeLocal n)
075: throws HeroHookException {
076: }
077:
078: public void afterStart(Object b, BnNodeLocal n)
079: throws HeroHookException {
080: }
081:
082: public void onReady(Object b, BnNodeLocal n)
083: throws HeroHookException {
084: try {
085:
086: BnProjectLocal project = n.getBnProject();
087: String prjName = project.getName();
088:
089: ProjectSessionHome prjhome = (ProjectSessionHome) ProjectSessionUtil
090: .getHome();
091: ProjectSession prjSession = prjhome.create();
092: prjSession.initProject(prjName);
093:
094: String nodeName = n.getName();
095:
096: TreeSet setSCRoles = new TreeSet();
097: setSCRoles.add("newValue");
098:
099: ArrayList arDefault = new ArrayList();
100: arDefault.add("newValue");
101:
102: prjSession.updateNodePropertyPossibleValues(nodeName,
103: "enumdyn", setSCRoles, arDefault);
104:
105: prjSession.setNodeProperty(nodeName, "testProp", "yes");
106:
107: } catch (Exception e) {
108: throw new HeroHookException(e.getMessage());
109: }
110: }
111:
112: }
|